From 7c812d7c9089a4c36ed388565dc7429ac4233639 Mon Sep 17 00:00:00 2001 From: AnchorArray Date: Mon, 9 Dec 2024 15:31:03 -0700 Subject: [PATCH] fix env quoteing and conditionally set cache endpoint env --- charts/guardrails/CHANGELOG.md | 5 +++++ charts/guardrails/README.md | 2 +- charts/guardrails/templates/deployment.yaml | 2 +- charts/guardrails/values.yaml | 5 ++--- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/charts/guardrails/CHANGELOG.md b/charts/guardrails/CHANGELOG.md index 6ca4132..f2c5df1 100644 --- a/charts/guardrails/CHANGELOG.md +++ b/charts/guardrails/CHANGELOG.md @@ -14,6 +14,11 @@ and this project adheres to [Semantic Versioning] previous chart versions. The cache layer deployment selector labels have been updated to be independently unique. +### Changed + +- Conditionally set `WHYLABS_API_CACHE_ENDPOINT` environment variable based on + the `cache.enable` value. + ## [0.5.0] - 2024-12-02 ### Added diff --git a/charts/guardrails/README.md b/charts/guardrails/README.md index 0952484..afcd6a4 100644 --- a/charts/guardrails/README.md +++ b/charts/guardrails/README.md @@ -290,7 +290,7 @@ autoscaling: | cache.labels | object | `{}` | Labels for the cache. | | cache.replicaCount | int | `1` | Number of replicas for the cache. | | commonLabels | object | `{}` | Labels to add to all chart resources. | -| env | object | `{}` | [Environment variables](https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/) for the `guardrails` container. **Supports Helm templating syntax**, e.g. you can use `{{ .Release.Name }}` or other templating variables, functions, and conditions within the the value of each environment variable. | +| env | object | `{"CONFIG_SYNC_INTERVAL":"1","TENANCY_MODE":"{{ .Values.tenancyMode | default \"SINGLE\" }}","WHYLABS_API_CACHE_ENDPOINT":"{{ if .Values.cache.enable }}{{ .Release.Name }}.{{ .Release.Namespace }}.svc.cluster.local{{ else }}{{ end }}"}` | [Environment variables](https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/) for the `guardrails` container. **Supports Helm templating syntax**, e.g. you can use `{{ .Release.Name }}` or other templating variables, functions, and conditions within the the value of each environment variable. | | envFrom | list | `[{"secretRef":{"name":"whylabs-guardrails-api-key","optional":true}},{"secretRef":{"name":"whylabs-guardrails-api-secret","optional":true}}]` | Create environment variables from Kubernetes secrets or config maps. | | envFrom[0].secretRef.name | string | `"whylabs-guardrails-api-key"` | Name of the Kubernetes secret containing the API key. The secret must be in the same namespace as the release and should be created prior to installing the chart. | | envFrom[1].secretRef.name | string | `"whylabs-guardrails-api-secret"` | Name of the Kubernetes secret containing the container password, the value used when executing requests against the guardrails container. The secret must be in the same namespace as the release and should be created prior to installing the chart. | diff --git a/charts/guardrails/templates/deployment.yaml b/charts/guardrails/templates/deployment.yaml index e9c3f58..136aabd 100644 --- a/charts/guardrails/templates/deployment.yaml +++ b/charts/guardrails/templates/deployment.yaml @@ -47,7 +47,7 @@ spec: env: {{- range $key, $value := .Values.env }} - name: {{ $key }} - value: {{ tpl $value $ }} + value: {{ tpl $value $ | quote }} {{- end }} {{- end }} {{- if .Values.envFrom }} diff --git a/charts/guardrails/values.yaml b/charts/guardrails/values.yaml index 8f4771a..4af725c 100644 --- a/charts/guardrails/values.yaml +++ b/charts/guardrails/values.yaml @@ -68,10 +68,9 @@ commonLabels: {} # for the `guardrails` container. **Supports Helm templating syntax**, e.g. you can use `{{ .Release.Name }}` or other # templating variables, functions, and conditions within the the value of each environment variable. env: - # Uncomment WHYLABS_API_CACHE_ENDPOINT if .Values.cache.enable is true - # WHYLABS_API_CACHE_ENDPOINT: "{{ .Release.Name }}.{{ .Release.Namespace }}.svc.cluster.local" - # @ignored + WHYLABS_API_CACHE_ENDPOINT: "{{ if .Values.cache.enable }}{{ .Release.Name }}.{{ .Release.Namespace }}.svc.cluster.local{{ else }}{{ end }}" TENANCY_MODE: "{{ .Values.tenancyMode | default \"SINGLE\" }}" + CONFIG_SYNC_INTERVAL: "1" # -- Create environment variables from Kubernetes secrets or config maps. envFrom: