Skip to content

Commit 94c6719

Browse files
committed
feat(cluster): add support for env and envFrom
- introduce `cluster.env` and `cluster.envFrom` in values.yaml - render them conditionally in templates/cluster.yaml under the Postgres container
1 parent e619cdd commit 94c6719

File tree

5 files changed

+47
-1
lines changed

5 files changed

+47
-1
lines changed

charts/cloudnative-pg/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,5 @@ CloudNativePG Operator Helm Chart
8181
| updateStrategy | object | `{}` | Update strategy for the operator. ref: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy For example: type: RollingUpdate rollingUpdate: maxSurge: 25% maxUnavailable: 25% |
8282
| webhook | object | `{"livenessProbe":{"initialDelaySeconds":3},"mutating":{"create":true,"failurePolicy":"Fail"},"port":9443,"readinessProbe":{"initialDelaySeconds":3},"startupProbe":{"failureThreshold":6,"periodSeconds":5},"validating":{"create":true,"failurePolicy":"Fail"}}` | The webhook configuration. |
8383

84+
----------------------------------------------
85+
Autogenerated from chart metadata using [helm-docs v1.14.2](https://github.com/norwoodj/helm-docs/releases/v1.14.2)

charts/cluster/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ refer to the [CloudNativePG Documentation](https://cloudnative-pg.io/documentat
155155
| cluster.certificates | object | `{}` | The configuration for the CA and related certificates. See: https://cloudnative-pg.io/documentation/current/cloudnative-pg.v1/#postgresql-cnpg-io-v1-CertificatesConfiguration |
156156
| cluster.enablePDB | bool | `true` | Allow to disable PDB, mainly useful for upgrade of single-instance clusters or development purposes See: https://cloudnative-pg.io/documentation/current/kubernetes_upgrade/#pod-disruption-budgets |
157157
| cluster.enableSuperuserAccess | bool | `true` | When this option is enabled, the operator will use the SuperuserSecret to update the postgres user password. If the secret is not present, the operator will automatically create one. When this option is disabled, the operator will ignore the SuperuserSecret content, delete it when automatically created, and then blank the password of the postgres user by setting it to NULL. |
158+
| cluster.env | list | `[]` | Env follows the Env format to pass environment variables to the pods created in the cluster |
159+
| cluster.envFrom | list | `[]` | EnvFrom follows the EnvFrom format to pass environment variables sources to the pods to be used by Env |
158160
| cluster.imageCatalogRef | object | `{}` | Reference to `ImageCatalog` of `ClusterImageCatalog`, if specified takes precedence over `cluster.imageName` |
159161
| cluster.imageName | string | `""` | Name of the container image, supporting both tags (<image>:<tag>) and digests for deterministic and repeatable deployments: <image>:<tag>@sha256:<digestValue> |
160162
| cluster.imagePullPolicy | string | `"IfNotPresent"` | Image pull policy. One of Always, Never or IfNotPresent. If not defined, it defaults to IfNotPresent. Cannot be updated. More info: https://kubernetes.io/docs/concepts/containers/images#updating-images |
@@ -307,3 +309,5 @@ TODO
307309
* IAM Role for S3 Service Account
308310
* Automatic provisioning of a Alert Manager configuration
309311

312+
----------------------------------------------
313+
Autogenerated from chart metadata using [helm-docs v1.14.2](https://github.com/norwoodj/helm-docs/releases/v1.14.2)

charts/cluster/templates/cluster.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ spec:
4242
affinity:
4343
{{- toYaml . | nindent 4 }}
4444
{{- end }}
45+
{{- if .Values.cluster.env }}
46+
env:
47+
{{ toYaml .Values.cluster.env | indent 4 }}
48+
{{- end }}
49+
{{- if .Values.cluster.envFrom }}
50+
envFrom:
51+
{{ toYaml .Values.cluster.envFrom | indent 4 }}
52+
{{- end }}
4553
{{- if .Values.cluster.priorityClassName }}
4654
priorityClassName: {{ .Values.cluster.priorityClassName }}
4755
{{- end }}

charts/cluster/values.schema.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "http://json-schema.org/schema#",
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
33
"type": "object",
44
"properties": {
55
"backups": {
@@ -193,6 +193,12 @@
193193
"enableSuperuserAccess": {
194194
"type": "boolean"
195195
},
196+
"env": {
197+
"type": "array"
198+
},
199+
"envFrom": {
200+
"type": "array"
201+
},
196202
"imageCatalogRef": {
197203
"type": "object"
198204
},

charts/cluster/values.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,32 @@ cluster:
249249
affinity:
250250
topologyKey: topology.kubernetes.io/zone
251251

252+
# -- Env follows the Env format to pass environment variables to the pods created in the cluster
253+
env: []
254+
# - name: MY_CUSTOM_FLAG
255+
# value: "enabled"
256+
# - name: MY_CUSTROM_ENV
257+
# valueFrom:
258+
# configMapKeyRef:
259+
# name: my-custom-env
260+
# key: env
261+
# optional: true
262+
# - name: MY_CUSTOM_SECRET_ENV
263+
# valueFrom:
264+
# secretKeyRef:
265+
# name: my-custom-secret
266+
# key: secret
267+
# optional: true
268+
269+
# -- EnvFrom follows the EnvFrom format to pass environment variables sources to the pods to be used by Env
270+
envFrom: []
271+
# - configMapRef:
272+
# name: global-envs
273+
# optional: true
274+
# - secretRef:
275+
# name: db-credentials
276+
# optional: true
277+
252278
# -- The configuration for the CA and related certificates.
253279
# See: https://cloudnative-pg.io/documentation/current/cloudnative-pg.v1/#postgresql-cnpg-io-v1-CertificatesConfiguration
254280
certificates: {}

0 commit comments

Comments
 (0)