Skip to content

Commit

Permalink
feat: Add SubPathExpr option for additionalVolumes
Browse files Browse the repository at this point in the history
  • Loading branch information
smutel authored and Samuel Mutel committed Jan 8, 2024
1 parent 409e4c7 commit 3e9caaf
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 7 deletions.
9 changes: 7 additions & 2 deletions charts/postgres-operator/crds/postgresqls.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,13 @@ spec:
volumeSource:
type: object
x-kubernetes-preserve-unknown-fields: true
subPath:
type: string
oneOf:
- properties:
subPath:
type: string
- properties:
subPathExpr:
type: string
allowedSourceRanges:
type: array
nullable: true
Expand Down
3 changes: 2 additions & 1 deletion docs/reference/cluster_manifest.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ These parameters are grouped directly under the `spec` key in the manifest.
[kubernetes volumeSource](https://godoc.org/k8s.io/api/core/v1#VolumeSource).
It allows you to mount existing PersistentVolumeClaims, ConfigMaps and Secrets inside the StatefulSet.
Also an `emptyDir` volume can be shared between initContainer and statefulSet.
Additionaly, you can provide a `SubPath` for volume mount (a file in a configMap source volume, for example).
Additionaly, you can provide a `SubPath` for volume mount (a file in a configMap source volume, for example)
or a `SubPathExpr`.
You can also specify in which container the additional Volumes will be mounted with the `targetContainers` array option.
If `targetContainers` is empty, additional volumes will be mounted only in the `postgres` container.
If you set the `all` special item, it will be mounted in all containers (postgres + sidecars).
Expand Down
9 changes: 9 additions & 0 deletions manifests/complete-postgres-manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ spec:
# PersistentVolumeClaim:
# claimName: pvc-postgresql-data-partitions
# readyOnly: false
# - name: data
# mountPath: /home/postgres/pgdata/partitions
# subPathExpr: $(NODE_NAME)/$(POD_NAME)
# targetContainers:
# - postgres
# volumeSource:
# PersistentVolumeClaim:
# claimName: pvc-postgresql-data-partitions
# readyOnly: false
# - name: conf
# mountPath: /etc/telegraf
# subPath: telegraf.conf
Expand Down
9 changes: 7 additions & 2 deletions manifests/postgresql.crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,13 @@ spec:
volumeSource:
type: object
x-kubernetes-preserve-unknown-fields: true
subPath:
type: string
oneOf:
- properties:
subPath:
type: string
- properties:
subPathExpr:
type: string
allowedSourceRanges:
type: array
nullable: true
Expand Down
17 changes: 15 additions & 2 deletions pkg/apis/acid.zalan.do/v1/crds.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,21 @@ var PostgresCRDResourceValidation = apiextv1.CustomResourceValidation{
Type: "object",
XPreserveUnknownFields: util.True(),
},
"subPath": {
Type: "string",
},
OneOf: []apiextv1.JSONSchemaProps{
{
Properties: map[string]apiextv1.JSONSchemaProps{
"subPath": {
Type: "string",
},
},
},
{
Properties: map[string]apiextv1.JSONSchemaProps{
"subPathExpr": {
Type: "string",
},
},
},
},
},
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/acid.zalan.do/v1/postgresql_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ type AdditionalVolume struct {
Name string `json:"name"`
MountPath string `json:"mountPath"`
SubPath string `json:"subPath,omitempty"`
SubPathExpr string `json:"subPathExpr,omitemtpy"`
TargetContainers []string `json:"targetContainers"`
VolumeSource v1.VolumeSource `json:"volumeSource"`
}
Expand Down

0 comments on commit 3e9caaf

Please sign in to comment.