Skip to content

Commit 25bc8cc

Browse files
committed
feat: Add SubPathExpr option for additionalVolumes
1 parent 409e4c7 commit 25bc8cc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+4033
-387
lines changed

charts/postgres-operator/crds/postgresqls.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,13 @@ spec:
9999
volumeSource:
100100
type: object
101101
x-kubernetes-preserve-unknown-fields: true
102-
subPath:
103-
type: string
102+
oneOf:
103+
- properties:
104+
subPath:
105+
type: string
106+
- properties:
107+
subPathExpr:
108+
type: string
104109
allowedSourceRanges:
105110
type: array
106111
nullable: true

docs/reference/cluster_manifest.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,8 @@ These parameters are grouped directly under the `spec` key in the manifest.
226226
[kubernetes volumeSource](https://godoc.org/k8s.io/api/core/v1#VolumeSource).
227227
It allows you to mount existing PersistentVolumeClaims, ConfigMaps and Secrets inside the StatefulSet.
228228
Also an `emptyDir` volume can be shared between initContainer and statefulSet.
229-
Additionaly, you can provide a `SubPath` for volume mount (a file in a configMap source volume, for example).
229+
Additionaly, you can provide a `SubPath` for volume mount (a file in a configMap source volume, for example)
230+
or a `SubPathExpr`.
230231
You can also specify in which container the additional Volumes will be mounted with the `targetContainers` array option.
231232
If `targetContainers` is empty, additional volumes will be mounted only in the `postgres` container.
232233
If you set the `all` special item, it will be mounted in all containers (postgres + sidecars).

manifests/complete-postgres-manifest.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,15 @@ spec:
8181
# PersistentVolumeClaim:
8282
# claimName: pvc-postgresql-data-partitions
8383
# readyOnly: false
84+
# - name: data
85+
# mountPath: /home/postgres/pgdata/partitions
86+
# subPathExpr: $(NODE_NAME)/$(POD_NAME)
87+
# targetContainers:
88+
# - postgres
89+
# volumeSource:
90+
# PersistentVolumeClaim:
91+
# claimName: pvc-postgresql-data-partitions
92+
# readyOnly: false
8493
# - name: conf
8594
# mountPath: /etc/telegraf
8695
# subPath: telegraf.conf

manifests/postgresql.crd.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,13 @@ spec:
9797
volumeSource:
9898
type: object
9999
x-kubernetes-preserve-unknown-fields: true
100-
subPath:
101-
type: string
100+
oneOf:
101+
- properties:
102+
subPath:
103+
type: string
104+
- properties:
105+
subPathExpr:
106+
type: string
102107
allowedSourceRanges:
103108
type: array
104109
nullable: true

pkg/apis/acid.zalan.do/v1/crds.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ var PostgresCRDResourceValidation = apiextv1.CustomResourceValidation{
167167
"subPath": {
168168
Type: "string",
169169
},
170+
"subPathExpr": {
171+
Type: "string",
172+
},
170173
},
171174
},
172175
},

pkg/apis/acid.zalan.do/v1/postgresql_type.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ type AdditionalVolume struct {
141141
Name string `json:"name"`
142142
MountPath string `json:"mountPath"`
143143
SubPath string `json:"subPath,omitempty"`
144+
SubPathExpr string `json:"subPathExpr,omitemtpy"`
144145
TargetContainers []string `json:"targetContainers"`
145146
VolumeSource v1.VolumeSource `json:"volumeSource"`
146147
}

pkg/apis/zalando.org/v1/zz_generated.deepcopy.go

Lines changed: 0 additions & 280 deletions
This file was deleted.

pkg/cluster/k8sres.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1752,9 +1752,10 @@ func (c *Cluster) addAdditionalVolumes(podSpec *v1.PodSpec,
17521752
for _, target := range additionalVolume.TargetContainers {
17531753
if podSpec.Containers[i].Name == target || target == "all" {
17541754
mounts = append(mounts, v1.VolumeMount{
1755-
Name: additionalVolume.Name,
1756-
MountPath: additionalVolume.MountPath,
1757-
SubPath: additionalVolume.SubPath,
1755+
Name: additionalVolume.Name,
1756+
MountPath: additionalVolume.MountPath,
1757+
SubPath: additionalVolume.SubPath,
1758+
SubPathExpr: additionalVolume.SubPathExpr,
17581759
})
17591760
}
17601761
}

0 commit comments

Comments
 (0)