diff --git a/charts/ext-postgres-operator/Chart.yaml b/charts/ext-postgres-operator/Chart.yaml index ccb6303b..afc59551 100644 --- a/charts/ext-postgres-operator/Chart.yaml +++ b/charts/ext-postgres-operator/Chart.yaml @@ -11,7 +11,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 1.2.3 +version: 1.2.4 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/charts/ext-postgres-operator/templates/_helpers.tpl b/charts/ext-postgres-operator/templates/_helpers.tpl index 427461c7..e5a15043 100644 --- a/charts/ext-postgres-operator/templates/_helpers.tpl +++ b/charts/ext-postgres-operator/templates/_helpers.tpl @@ -61,3 +61,35 @@ Create the name of the service account to use {{- define "chart.serviceAccountName" -}} {{- default (include "chart.fullname" .) .Values.serviceAccount.name }} {{- end }} + +{{/* +Generate list of env vars from dics of env vars +*/}} +{{- define "envVarsMap" -}} +{{- $map := . -}} +{{- range $key := $map | keys | sortAlpha -}} +{{- $val := get $map $key }} +- name: {{ $key }} +{{- if or (kindIs "map" $val) (kindIs "slice" $val) }} +{{ $val | toYaml | indent 2 }} +{{- else }} + value: {{ $val | quote}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Gets a dict of env vars and return list of name,value dicts +*/}} +{{- define "utils.sortedEnvVars" -}} +{{- $dict := . -}} +{{- range $key := $dict | keys | sortAlpha -}} +{{- $val := get $dict $key }} +- name: {{ $key }} +{{- if or (kindIs "map" $val) (kindIs "slice" $val) }} +{{ $val | toYaml | indent 2 }} +{{- else }} + value: {{ $val | quote}} +{{- end -}} +{{- end -}} +{{- end -}} diff --git a/charts/ext-postgres-operator/templates/operator.yaml b/charts/ext-postgres-operator/templates/operator.yaml index 2c46ba34..f68ac167 100644 --- a/charts/ext-postgres-operator/templates/operator.yaml +++ b/charts/ext-postgres-operator/templates/operator.yaml @@ -33,13 +33,11 @@ spec: command: - postgres-operator imagePullPolicy: {{ .Values.image.pullPolicy }} + {{- if or (.Values.postgres.secretName) (eq .Values.postgres.createSecret true) }} envFrom: - secretRef: - {{- if .Values.existingSecret }} - name: {{ .Values.existingSecret }} - {{- else }} - name: {{ include "chart.fullname" . }} - {{- end }} + name: {{ .Values.postgres.secretName }} + {{- end }} env: - name: WATCH_NAMESPACE value: {{ .Values.watchNamespace | default "" }} @@ -49,6 +47,7 @@ spec: fieldPath: metadata.name - name: OPERATOR_NAME value: {{ include "chart.fullname" . }} + {{- include "envVarsMap" .Values.envVars | nindent 12 }} {{- range $key, $value := .Values.env }} - name: {{ $key }} value: {{ $value }} diff --git a/charts/ext-postgres-operator/templates/secret.yaml b/charts/ext-postgres-operator/templates/secret.yaml index a245cbe4..42cb7b2f 100644 --- a/charts/ext-postgres-operator/templates/secret.yaml +++ b/charts/ext-postgres-operator/templates/secret.yaml @@ -1,11 +1,11 @@ -{{- if (not .Values.existingSecret) }} ---- + +{{- if and .Values.postgres.createSecret }} apiVersion: v1 kind: Secret metadata: annotations: "helm.sh/resource-policy": keep - name: {{ include "chart.fullname" . }} + name: {{ .Values.postgres.secretName }} namespace: {{ .Release.namespace }} labels: {{- include "chart.labels" . | nindent 4 }} @@ -17,4 +17,4 @@ data: POSTGRES_URI_ARGS: {{ .Values.postgres.uri_args | b64enc | quote }} POSTGRES_CLOUD_PROVIDER: {{ .Values.postgres.cloud_provider | b64enc | quote }} POSTGRES_DEFAULT_DATABASE: {{ .Values.postgres.default_database | b64enc | quote }} -{{- end }} +{{- end -}} diff --git a/charts/ext-postgres-operator/values.yaml b/charts/ext-postgres-operator/values.yaml index 11089940..83538392 100644 --- a/charts/ext-postgres-operator/values.yaml +++ b/charts/ext-postgres-operator/values.yaml @@ -5,10 +5,10 @@ replicaCount: 1 image: - repository: ghcr.io/movetokube/postgres-operator + repository: movetokube/postgres-operator pullPolicy: IfNotPresent # Overrides the image tag whose default is the chart appVersion. - tag: "latest" + tag: "" # Override chart name, defaults to Chart.name nameOverride: "" @@ -24,9 +24,6 @@ serviceAccount: podAnnotations: {} -# Additionnal labels to add to the pod. -podLabels: {} - podSecurityContext: {} # fsGroup: 2000 @@ -45,8 +42,17 @@ resources: {} # Which namespace to watch in kubernetes, empty string means all namespaces watchNamespace: "" +#Enables to add env vars as dict +envVars: {} + # ENV_VAR_1: "aa" + # ENV_VAR_2: "bb" + # Define connection to postgres database server postgres: + # Whether to create the secret file or not + createSecret: true + # The name of the secret + secretName: "ext-postgres-operator" # postgres hostname host: "localhost" # postgres admin user and password @@ -58,20 +64,3 @@ postgres: cloud_provider: "" # default database to use default_database: "postgres" - -# Volumes to add to the pod. -volumes: [] - -# Volumes to mount onto the pod. -volumeMounts: [] - -# Existing secret where values to connect to Postgres are defined. -# If not set a new secret will be created, filled with information under the postgres key above. -existingSecret: "" - -# Additionnal environment variables to add to the pod (map of key / value) -env: {} - -nodeSelector: {} - -tolerations: []