Skip to content

Commit f4633c8

Browse files
jaitaiwanandrewlecuyer
authored andcommitted
feat: Add customised env var and feature flags
This change adds 3 new features: - The ability to enable feature flags with the .Values.features key - The ability to add extra environment variables to the container env - The ability to completely override env variables (not recommended) Closes CrunchyData#262
1 parent 5dacafa commit f4633c8

File tree

3 files changed

+66
-15
lines changed

3 files changed

+66
-15
lines changed

helm/install/templates/_helpers.tpl

+34
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,37 @@ imagePullSecrets:
9898
value: {{ $object.image | quote }}
9999
{{- end }}
100100
{{- end }}
101+
102+
103+
{{- define "install.defaultEnv" -}}
104+
- name: CRUNCHY_DEBUG
105+
value: {{ .Values.debug | ne false | quote }}
106+
- name: PGO_NAMESPACE
107+
valueFrom: { fieldRef: { apiVersion: v1, fieldPath: metadata.namespace } }
108+
{{- if .Values.singleNamespace }}
109+
- name: PGO_TARGET_NAMESPACE
110+
valueFrom: { fieldRef: { apiVersion: v1, fieldPath: metadata.namespace } }
111+
{{- end }}
112+
{{- if .Values.workers }}
113+
- name: PGO_WORKERS
114+
value: {{ .Values.workers | quote }}
115+
{{- end }}
116+
{{- include "install.relatedImages" . }}
117+
{{- if .Values.disable_check_for_upgrades }}
118+
- name: CHECK_FOR_UPGRADES
119+
value: "false"
120+
{{- end }}
121+
{{- if .Values.features }}
122+
{{- $value := .Values.features }}
123+
- name: PGO_FEATURE_GATES
124+
{{- $out := "" -}}
125+
{{- if eq (kindOf $value) "map" -}}
126+
{{- range $key, $val := $value -}}
127+
{{- $out = (print $out $key "=" $val ",") -}}
128+
{{- end }}
129+
{{- end }}
130+
value: "{{ trimSuffix "," $out }}"
131+
{{- end }}
132+
{{- end }}{{/* define */}}
133+
134+

helm/install/templates/manager.yaml

+6-15
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,13 @@ spec:
2424
- name: operator
2525
image: {{ required ".Values.controllerImages.cluster is required" .Values.controllerImages.cluster | quote }}
2626
env:
27-
- name: CRUNCHY_DEBUG
28-
value: {{ .Values.debug | ne false | quote }}
29-
- name: PGO_NAMESPACE
30-
valueFrom: { fieldRef: { apiVersion: v1, fieldPath: metadata.namespace } }
31-
{{- if .Values.singleNamespace }}
32-
- name: PGO_TARGET_NAMESPACE
33-
valueFrom: { fieldRef: { apiVersion: v1, fieldPath: metadata.namespace } }
27+
{{- if .Values.envOverride }}
28+
{{- toYaml .Values.envOverride | nindent 10 }}
29+
{{- else -}}
30+
{{- include "install.defaultEnv" . | nindent 10 }}
3431
{{- end }}
35-
{{- if .Values.workers }}
36-
- name: PGO_WORKERS
37-
value: {{ .Values.workers | quote }}
38-
{{- end }}
39-
{{- include "install.relatedImages" . | indent 8 }}
40-
{{- if .Values.disable_check_for_upgrades }}
41-
- name: CHECK_FOR_UPGRADES
42-
value: "false"
32+
{{- if .Values.extraEnv }}
33+
{{- toYaml .Values.extraEnv | nindent 10 }}
4334
{{- end }}
4435
{{- if .Values.resources.controller }}
4536
resources:

helm/install/values.yaml

+26
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,29 @@ resources:
4949
# postgres-operator.crunchydata.com, will cause an error
5050
# customPodLabels:
5151
# example.com: custom-label
52+
53+
# Enable feature gates for PGO, by explicitly seting the value for the flags
54+
# features:
55+
# AutoGrowVolumes: true
56+
# Feature2: false
57+
# Feature3: somevalue
58+
59+
# Define extra environment variables for the chart, which will get added to the container's env
60+
# extraEnv:
61+
# - name: MY_VAR
62+
# value: "myvalue"
63+
# - name: MY_CONFIGMAP_VAR
64+
# valueFrom:
65+
# configMapKeyRef:
66+
# name: s3-settings
67+
# key: bucket
68+
# - name: MY_SECRET_VAR
69+
# valueFrom:
70+
# secretKeyRef:
71+
# name: s3-secret
72+
# key: key
73+
74+
# Override environment variables entirely !!DANGEROUS!!
75+
# envOverride:
76+
# - name: PG_DEBUG
77+
# value: "true"

0 commit comments

Comments
 (0)