From 10e831825a4f21f1e75b0f38d5a9dff592982824 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Marchand?= <1673467+uncycler@users.noreply.github.com> Date: Thu, 30 Mar 2023 15:37:08 +0200 Subject: [PATCH] bug(helm): Fix parsing error with statefulset (#985) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix parsing error with persistence and password secret configuration --------- Signed-off-by: Frédéric Marchand Co-authored-by: Tarun Pothulapati --- .pre-commit-config.yaml | 1 + .../ci/passwordsecret-values.golden.yaml | 1 + ...ersistence-and-existing-secret.golden.yaml | 120 ++++++++++++++++++ .../ci/persistence-and-existing-secret.yaml | 18 +++ contrib/charts/dragonfly/templates/_pod.tpl | 2 +- 5 files changed, 141 insertions(+), 1 deletion(-) create mode 100644 contrib/charts/dragonfly/ci/persistence-and-existing-secret.golden.yaml create mode 100644 contrib/charts/dragonfly/ci/persistence-and-existing-secret.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2384c99e5..b1599f856 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,6 @@ default_stages: [commit] exclude: 'src\/redis\/.*' +exclude: 'contrib\/charts\/dragonfly\/ci\/.*' repos: - repo: local hooks: diff --git a/contrib/charts/dragonfly/ci/passwordsecret-values.golden.yaml b/contrib/charts/dragonfly/ci/passwordsecret-values.golden.yaml index 26d8f3af3..766cd1021 100644 --- a/contrib/charts/dragonfly/ci/passwordsecret-values.golden.yaml +++ b/contrib/charts/dragonfly/ci/passwordsecret-values.golden.yaml @@ -99,6 +99,7 @@ spec: resources: limits: {} requests: {} + env: - name: DFLY_PASSWORD valueFrom: diff --git a/contrib/charts/dragonfly/ci/persistence-and-existing-secret.golden.yaml b/contrib/charts/dragonfly/ci/persistence-and-existing-secret.golden.yaml new file mode 100644 index 000000000..f72a45720 --- /dev/null +++ b/contrib/charts/dragonfly/ci/persistence-and-existing-secret.golden.yaml @@ -0,0 +1,120 @@ +--- +# 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.0.0" + app.kubernetes.io/managed-by: Helm +--- +# Source: dragonfly/templates/extra-manifests.yaml +apiVersion: v1 +kind: Secret +metadata: + name: dfly-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.0.0" + 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/statefulset.yaml +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: test-dragonfly + namespace: default + labels: + app.kubernetes.io/name: dragonfly + app.kubernetes.io/instance: test + app.kubernetes.io/version: "v1.0.0" + app.kubernetes.io/managed-by: Helm +spec: + serviceName: test + 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.0.0" + 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: {} + volumeMounts: + - mountPath: /data + name: "test-data" + env: + - name: DFLY_PASSWORD + valueFrom: + secretKeyRef: + name: dfly-password + key: password + volumeClaimTemplates: + - metadata: + name: "test-data" + spec: + accessModes: [ "ReadWriteOnce" ] + storageClassName: standard + resources: + requests: + storage: 128Mi diff --git a/contrib/charts/dragonfly/ci/persistence-and-existing-secret.yaml b/contrib/charts/dragonfly/ci/persistence-and-existing-secret.yaml new file mode 100644 index 000000000..d50dc99fd --- /dev/null +++ b/contrib/charts/dragonfly/ci/persistence-and-existing-secret.yaml @@ -0,0 +1,18 @@ +storage: + enabled: true + storageClassName: "standard" + requests: 128Mi + +extraObjects: +- apiVersion: v1 + kind: Secret + metadata: + name: dfly-password + stringData: + password: foobar + +passwordFromSecret: + enable: true + existingSecret: + name: dfly-password + key: password diff --git a/contrib/charts/dragonfly/templates/_pod.tpl b/contrib/charts/dragonfly/templates/_pod.tpl index 04d5cda21..499099d04 100644 --- a/contrib/charts/dragonfly/templates/_pod.tpl +++ b/contrib/charts/dragonfly/templates/_pod.tpl @@ -86,7 +86,7 @@ containers: {{- toYaml . | trim | nindent 6 }} {{- end }} {{- include "dragonfly.volumemounts" . | trim | nindent 4 }} - {{- if .Values.passwordFromSecret.enable -}} + {{- if .Values.passwordFromSecret.enable }} env: - name: DFLY_PASSWORD valueFrom: