Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable to provide secrets from outer secret and not only from the sec… #107

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion charts/ext-postgres-operator/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 32 additions & 0 deletions charts/ext-postgres-operator/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}
9 changes: 4 additions & 5 deletions charts/ext-postgres-operator/templates/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 "" }}
Expand All @@ -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 }}
Expand Down
8 changes: 4 additions & 4 deletions charts/ext-postgres-operator/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
Expand All @@ -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 -}}
33 changes: 11 additions & 22 deletions charts/ext-postgres-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: ""
Expand All @@ -24,9 +24,6 @@ serviceAccount:

podAnnotations: {}

# Additionnal labels to add to the pod.
podLabels: {}

podSecurityContext: {}
# fsGroup: 2000

Expand All @@ -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
Expand All @@ -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: []