diff --git a/contrib/charts/dragonfly/README.md b/contrib/charts/dragonfly/README.md index 1e183dfe6..7308e7e6c 100644 --- a/contrib/charts/dragonfly/README.md +++ b/contrib/charts/dragonfly/README.md @@ -66,6 +66,8 @@ helm upgrade --install dragonfly oci://ghcr.io/dragonflydb/dragonfly/helm/dragon | replicaCount | int | `1` | Number of replicas to deploy | | resources.limits | object | `{}` | The resource limits for the containers | | resources.requests | object | `{}` | The requested resources for the containers | +| env | list | `[]` | Extra environment variables | +| envFrom | list | `[]` | Extra environment variables from K8s objects | | securityContext | object | `{}` | Set securityContext for containers | | service.annotations | object | `{}` | Extra annotations for the service | | service.lablels | object | `{}` | Extra labels for the service | diff --git a/contrib/charts/dragonfly/ci/extraenv-and-passwordSecret-values.golden.yaml b/contrib/charts/dragonfly/ci/extraenv-and-passwordSecret-values.golden.yaml new file mode 100644 index 000000000..38b11d46e --- /dev/null +++ b/contrib/charts/dragonfly/ci/extraenv-and-passwordSecret-values.golden.yaml @@ -0,0 +1,136 @@ +--- +# 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.4" + 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/extra-manifests.yaml +apiVersion: v1 +kind: Secret +metadata: + name: my-secret +stringData: + password: password + username: username +type: Opaque +--- +# Source: dragonfly/templates/extra-manifests.yaml +apiVersion: v1 +data: + configKey1: configValue1 + configKey2: configValue2 +kind: ConfigMap +metadata: + name: my-configmap +--- +# 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.4" + 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.4" + 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.4" + 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: dfly-password + key: password + - name: ENV_VAR43 + value: value1 + - name: ENV_VAR323 + value: value2 + envFrom: + - configMapRef: + name: my-configmap + - secretRef: + name: my-secret diff --git a/contrib/charts/dragonfly/ci/extraenv-and-passwordSecret-values.yaml b/contrib/charts/dragonfly/ci/extraenv-and-passwordSecret-values.yaml new file mode 100644 index 000000000..d3a157eda --- /dev/null +++ b/contrib/charts/dragonfly/ci/extraenv-and-passwordSecret-values.yaml @@ -0,0 +1,40 @@ +extraObjects: +- apiVersion: v1 + kind: Secret + metadata: + name: dfly-password + stringData: + password: foobar +- apiVersion: v1 + kind: ConfigMap + metadata: + name: my-configmap + data: + configKey1: configValue1 + configKey2: configValue2 +- apiVersion: v1 + kind: Secret + metadata: + name: my-secret + type: Opaque + stringData: + username: username + password: password + +env: + - name: ENV_VAR43 + value: value1 + - name: ENV_VAR323 + value: value2 + +envFrom: + - configMapRef: + name: my-configmap + - secretRef: + name: my-secret + +passwordFromSecret: + enable: true + existingSecret: + name: dfly-password + key: password diff --git a/contrib/charts/dragonfly/ci/extraenv-values.golden.yaml b/contrib/charts/dragonfly/ci/extraenv-values.golden.yaml new file mode 100644 index 000000000..0edb9c26c --- /dev/null +++ b/contrib/charts/dragonfly/ci/extraenv-values.golden.yaml @@ -0,0 +1,123 @@ +--- +# 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.4" + app.kubernetes.io/managed-by: Helm +--- +# Source: dragonfly/templates/extra-manifests.yaml +apiVersion: v1 +kind: Secret +metadata: + name: my-secret +stringData: + password: password + username: username +type: Opaque +--- +# Source: dragonfly/templates/extra-manifests.yaml +apiVersion: v1 +data: + configKey1: configValue1 + configKey2: configValue2 +kind: ConfigMap +metadata: + name: my-configmap +--- +# 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.4" + 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.4" + 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.4" + 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: ENV_VAR43 + value: value1 + - name: ENV_VAR323 + value: value2 + envFrom: + - configMapRef: + name: my-configmap + - secretRef: + name: my-secret diff --git a/contrib/charts/dragonfly/ci/extraenv-values.yaml b/contrib/charts/dragonfly/ci/extraenv-values.yaml new file mode 100644 index 000000000..00c7c2258 --- /dev/null +++ b/contrib/charts/dragonfly/ci/extraenv-values.yaml @@ -0,0 +1,28 @@ +extraObjects: +- apiVersion: v1 + kind: ConfigMap + metadata: + name: my-configmap + data: + configKey1: configValue1 + configKey2: configValue2 +- apiVersion: v1 + kind: Secret + metadata: + name: my-secret + type: Opaque + stringData: + username: username + password: password + +env: + - name: ENV_VAR43 + value: value1 + - name: ENV_VAR323 + value: value2 + +envFrom: + - configMapRef: + name: my-configmap + - secretRef: + name: my-secret diff --git a/contrib/charts/dragonfly/templates/_pod.tpl b/contrib/charts/dragonfly/templates/_pod.tpl index 30bf81848..c73df261d 100644 --- a/contrib/charts/dragonfly/templates/_pod.tpl +++ b/contrib/charts/dragonfly/templates/_pod.tpl @@ -96,6 +96,8 @@ containers: {{- toYaml . | trim | nindent 6 }} {{- end }} {{- include "dragonfly.volumemounts" . | trim | nindent 4 }} + {{- if or .Values.passwordFromSecret.enable .Values.env }} + env: {{- if .Values.passwordFromSecret.enable }} {{- $appVersion := .Chart.AppVersion | trimPrefix "v" }} {{- $imageTag := .Values.image.tag | trimPrefix "v" }} @@ -103,7 +105,6 @@ containers: {{- if and $imageTag (ne $imageTag "") }} {{- $effectiveVersion = $imageTag }} {{- end }} - env: {{- if semverCompare ">=1.14.0" $effectiveVersion }} - name: DFLY_requirepass {{- else }} @@ -114,6 +115,14 @@ containers: name: {{ tpl .Values.passwordFromSecret.existingSecret.name $ }} key: {{ .Values.passwordFromSecret.existingSecret.key }} {{- end }} + {{- with .Values.env }} + {{- toYaml . | trim | nindent 6 }} + {{- end }} + {{- end }} + {{- with .Values.envFrom }} + envFrom: + {{- toYaml . | trim | nindent 6 }} + {{- end }} {{- if or (.Values.tls.enabled) (.Values.extraVolumes) }} volumes: diff --git a/contrib/charts/dragonfly/values.yaml b/contrib/charts/dragonfly/values.yaml index 3be6af208..6aecfee27 100644 --- a/contrib/charts/dragonfly/values.yaml +++ b/contrib/charts/dragonfly/values.yaml @@ -201,6 +201,12 @@ resources: # cpu: 100m # memory: 128Mi +# -- extra environment variables +env: [] + +# -- extra environment variables from K8s objects +envFrom: [] + # -- Priority class name for pod assignment priorityClassName: ""