Skip to content

Commit 9d3bad0

Browse files
feat: Helm-Chart Support External Secret Operator (#242)
* feat: Helm-Chart Support External Secret Operator / feat: support for reload when secret changed * Update charts/ext-postgres-operator/values.yaml Co-authored-by: Pieter C <[email protected]> * fix: values.yaml after code-review * fix: values.yaml after code-review :02 * fix: values.yaml after code-review :03 * fix: .Values.externalSecret --------- Co-authored-by: Pieter C <[email protected]>
1 parent b438e5d commit 9d3bad0

File tree

6 files changed

+63
-11
lines changed

6 files changed

+63
-11
lines changed

charts/ext-postgres-operator/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ description: |
88
99
type: application
1010

11-
version: 2.1.0
11+
version: 2.2.0
1212
appVersion: "2.0.0"
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{{- if and (.Capabilities.APIVersions.Has "external-secrets.io/v1beta1") (.Values.externalSecret) }}
2+
apiVersion: external-secrets.io/v1beta1
3+
kind: ExternalSecret
4+
metadata:
5+
name: {{ include "chart.fullname" . }}-external-secret
6+
namespace: {{ if .Values.externalSecret.namespace }}{{ .Values.externalSecret.namespace }}{{ else }}{{ .Release.Namespace }}{{ end }}
7+
labels:
8+
{{- include "chart.labels" . | nindent 4 }}
9+
spec:
10+
refreshInterval: {{ .Values.externalSecret.refreshInterval | default "2s"}}
11+
secretStoreRef:
12+
kind: {{ .Values.externalSecret.secretStoreKind | default "SecretStore" }}
13+
name: {{ .Values.externalSecret.secretStore | quote }}
14+
target:
15+
creationPolicy: Owner
16+
deletionPolicy: Retain
17+
name: {{ include "chart.fullname" . }}
18+
template:
19+
data:
20+
POSTGRES_HOST: {{ .Values.postgres.host | quote }}
21+
POSTGRES_USER: "{{ `{{ .username }}` }}"
22+
POSTGRES_PASS: "{{ `{{ .password }}` }}"
23+
POSTGRES_URI_ARGS: {{ .Values.postgres.uri_args | quote }}
24+
POSTGRES_CLOUD_PROVIDER: {{ .Values.postgres.cloud_provider | quote }}
25+
POSTGRES_DEFAULT_DATABASE: {{ .Values.postgres.default_database | quote }}
26+
data:
27+
- secretKey: username
28+
remoteRef:
29+
key: {{ .Values.externalSecret.remoteKey | quote }}
30+
property: username
31+
- secretKey: password
32+
remoteRef:
33+
key: {{ .Values.externalSecret.remoteKey | quote }}
34+
property: password
35+
{{- end }}

charts/ext-postgres-operator/templates/operator.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,14 @@ metadata:
55
labels:
66
{{- include "chart.labels" . | nindent 4 }}
77
namespace: {{ .Release.Namespace }}
8-
{{- with .Values.deploymentAnnotations }}
98
annotations:
9+
{{- if not .Values.externalSecret }}
10+
checksum/secret: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
11+
{{- end }}
12+
{{- if .Values.externalSecret }}
13+
checksum/external-secret: {{ include (print $.Template.BasePath "/external-secret.yaml") . | sha256sum }}
14+
{{- end }}
15+
{{- with .Values.deploymentAnnotations }}
1016
{{- toYaml . | nindent 4 }}
1117
{{- end }}
1218
spec:

charts/ext-postgres-operator/templates/secret.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
{{- if (not .Values.existingSecret) }}
1+
{{- if and (not .Values.existingSecret) (not .Values.externalSecret) }}
22
---
33
apiVersion: v1
44
kind: Secret
55
metadata:
66
annotations:
77
"helm.sh/resource-policy": keep
88
name: {{ include "chart.fullname" . }}
9-
namespace: {{ .Release.namespace }}
9+
namespace: {{ .Release.Namespace }}
1010
labels:
1111
{{- include "chart.labels" . | nindent 4 }}
1212
type: Opaque

charts/ext-postgres-operator/templates/serviceaccount.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ metadata:
99
{{- toYaml . | nindent 4 }}
1010
{{- end }}
1111
namespace: {{ .Release.Namespace }}
12-
12+
automountServiceAccountToken: {{ .Values.serviceAccount.automount }}

charts/ext-postgres-operator/values.yaml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,13 @@ serviceAccount:
2727
# The name of the service account to use.
2828
# If not set and create is true, a name is generated using the fullname template
2929
name: ""
30+
automount: true
3031

3132
deploymentAnnotations: {}
3233

3334
podAnnotations: {}
3435

35-
# Additionnal labels to add to the pod.
36+
# Additional labels to add to the pod.
3637
podLabels: {}
3738

3839
podSecurityContext:
@@ -45,8 +46,7 @@ securityContext:
4546
drop:
4647
- "ALL"
4748

48-
resources:
49-
{}
49+
resources: {}
5050
# We usually recommend not to specify default resources and to leave this as a conscious
5151
# choice for the user. This also increases chances charts run on environments with little
5252
# resources, such as Minikube. If you do want to specify resources, uncomment the following
@@ -80,10 +80,10 @@ watchNamespace: ""
8080
postgres:
8181
# postgres hostname
8282
host: "localhost"
83-
# postgres admin user and password
83+
# postgres admin user and password ( ignored if existingSecret or ExternalSecret is set )
8484
user: "admin"
8585
password: "password"
86-
# additional connection args to pg driver
86+
# additional connection args to pg driver (Example "sslmode=disable")
8787
uri_args: ""
8888
# postgres cloud provider, could be AWS, Azure, GCP or empty (default)
8989
cloud_provider: ""
@@ -98,10 +98,21 @@ volumeMounts: []
9898

9999
# Existing secret where values to connect to Postgres are defined.
100100
# If not set a new secret will be created, filled with information under the postgres key above.
101+
# If ExternalSecret is set, existingSecret is ignored.
101102
existingSecret: ""
102103

103-
# Additionnal environment variables to add to the pod (map of key / value)
104+
# Support for ExternalSecret Operator to fetch Postgres credentials from an external secret store.
105+
externalSecret: {}
106+
# secretStore: "aws-secretsmanager-euc1" # (Mandatory) Name of the SecretStore or ClusterSecretStore to reference in the ExternalSecret
107+
# remoteKey: "rds!db-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" # (Mandatory) Remote key in the external secret store where Postgres credentials are stored
108+
# namespace: "" # (Optional), defaults to release namespace
109+
# secretStoreKind: "" # (Optional), defaults to SecretStore / SecretStore or ClusterSecretStore
110+
# refreshInterval: "2s" # (Optional), defaults to SecretStore / SecretStore or ClusterSecretStore
111+
112+
# Additional environment variables to add to the pod (map of key / value)
104113
env: {}
114+
# POSTGRES_INSTANCE: "XXXXXXXXXX"
115+
# POSTGRES_CLOUD_PROVIDER: "AWS"
105116

106117
nodeSelector: {}
107118

0 commit comments

Comments
 (0)