Skip to content

Commit

Permalink
feat(contrib/helm): evaluate the provided passwordSecretName value as…
Browse files Browse the repository at this point in the history
… a template (#4046)

* feat(contrib/helm): evaluate the provided passwordSecretName value as a template

Useful to reuse some defined variables or functions directly to compute the value
(external chart for instance, that depends on this one)

example:
'{{ include "something.defined.elsewhere" $ }}-secrets'

Signed-off-by: Raphael Glon <[email protected]>

* update golden tests

---------

Signed-off-by: Raphael Glon <[email protected]>
Co-authored-by: Raphael Glon <[email protected]>
Co-authored-by: Tarun Pothulapati <[email protected]>
  • Loading branch information
3 people authored Nov 27, 2024
1 parent a87d6ae commit 1ceca47
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 3 deletions.
108 changes: 108 additions & 0 deletions contrib/charts/dragonfly/ci/passwordsecret-values.tpl.golden.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
---
# Source: dragonfly/templates/serviceaccount.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: test-dragonfly
namespace: default
labels:
app.kubernetes.io/name: dragonfly
app.kubernetes.io/instance: test
app.kubernetes.io/version: "v1.25.3"
app.kubernetes.io/managed-by: Helm
---
# Source: dragonfly/templates/extra-manifests.yaml
apiVersion: v1
kind: Secret
metadata:
name: dragonfly-password
stringData:
password: foobar
---
# Source: dragonfly/templates/service.yaml
apiVersion: v1
kind: Service
metadata:
name: test-dragonfly
namespace: default
labels:
app.kubernetes.io/name: dragonfly
app.kubernetes.io/instance: test
app.kubernetes.io/version: "v1.25.3"
app.kubernetes.io/managed-by: Helm
spec:
type: ClusterIP
ports:
- port: 6379
targetPort: dragonfly
protocol: TCP
name: dragonfly
selector:
app.kubernetes.io/name: dragonfly
app.kubernetes.io/instance: test
---
# Source: dragonfly/templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: test-dragonfly
namespace: default
labels:
app.kubernetes.io/name: dragonfly
app.kubernetes.io/instance: test
app.kubernetes.io/version: "v1.25.3"
app.kubernetes.io/managed-by: Helm
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: dragonfly
app.kubernetes.io/instance: test
template:
metadata:
annotations:
labels:
app.kubernetes.io/name: dragonfly
app.kubernetes.io/instance: test
spec:
serviceAccountName: test-dragonfly
containers:
- name: dragonfly
image: "docker.dragonflydb.io/dragonflydb/dragonfly:v1.25.3"
imagePullPolicy: IfNotPresent
ports:
- name: dragonfly
containerPort: 6379
protocol: TCP
livenessProbe:
exec:
command:
- /bin/sh
- /usr/local/bin/healthcheck.sh
failureThreshold: 3
initialDelaySeconds: 10
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 5
readinessProbe:
exec:
command:
- /bin/sh
- /usr/local/bin/healthcheck.sh
failureThreshold: 3
initialDelaySeconds: 10
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 5
args:
- "--alsologtostderr"
resources:
limits: {}
requests: {}

env:
- name: DFLY_requirepass
valueFrom:
secretKeyRef:
name: dragonfly-password
key: password
13 changes: 13 additions & 0 deletions contrib/charts/dragonfly/ci/passwordsecret-values.tpl.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
extraObjects:
- apiVersion: v1
kind: Secret
metadata:
name: dragonfly-password
stringData:
password: foobar

passwordFromSecret:
enable: true
existingSecret:
name: '{{ include "dragonfly.name" $ }}-password'
key: password
2 changes: 1 addition & 1 deletion contrib/charts/dragonfly/templates/_pod.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ containers:
{{- end }}
valueFrom:
secretKeyRef:
name: {{ .Values.passwordFromSecret.existingSecret.name }}
name: {{ tpl .Values.passwordFromSecret.existingSecret.name $ }}
key: {{ .Values.passwordFromSecret.existingSecret.key }}
{{- end }}

Expand Down
6 changes: 4 additions & 2 deletions go.work.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=

0 comments on commit 1ceca47

Please sign in to comment.