Skip to content

Commit 84d3378

Browse files
authored
feat (chart): add support for existing usecase secret (#235)
This pull request introduces support for referencing an externally managed Kubernetes Secret for usecase credentials, allowing teams to use the External Secrets Operator (ESO) or other solutions to manage secrets outside of Helm chart deployments. The chart will now use an existing Secret if specified, rather than creating a new one. **Support for externally managed usecase secrets:** * Added documentation in `infrastructure/README.md` explaining how to configure the chart to use an externally managed Secret via the new `usecaseExistingSecretName` value. * Updated `infrastructure/rag/values.yaml` to include the new `usecaseExistingSecretName` field under `shared.secrets`, with instructions for its usage. **Chart logic updates for conditional Secret creation:** * Modified `_helpers.tpl` to resolve the usecase Secret name to either the existing Secret or a generated name, depending on whether `usecaseExistingSecretName` is set. * Updated `secrets.yaml` to only create a new usecase Secret if `usecaseExistingSecretName` is not set, ensuring the chart does not overwrite externally managed secrets. [[1]](diffhunk://#diff-9e2edcc6f0d9600113b5f37de42319e2fa5290a228da6ef9d2f6dbcb7bb19014R12) [[2]](diffhunk://#diff-9e2edcc6f0d9600113b5f37de42319e2fa5290a228da6ef9d2f6dbcb7bb19014R22)
1 parent dd0889e commit 84d3378

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed

infrastructure/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,16 @@ shared:
459459
USECASE_SECRET_ENV_VAR: ...
460460
```
461461

462+
If you manage the usecase secret via External Secrets Operator, create the Secret in the target namespace and point the chart to it:
463+
464+
```yaml
465+
shared:
466+
secrets:
467+
usecaseExistingSecretName: "my-usecase-secret"
468+
```
469+
470+
When `usecaseExistingSecretName` is set, the chart will not create the usecase secret and will reference the existing one instead.
471+
462472
## 2. Requirements and Setup Instructions
463473

464474
The following section describes the requirements for the infrastructure setup and provides instructions for the local and production setup.

infrastructure/rag/templates/_helpers.tpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,12 @@
1515
{{- end -}}
1616

1717
{{- define "secret.usecaseName" -}}
18+
{{- if .Values.shared.secrets.usecaseExistingSecretName -}}
19+
{{- .Values.shared.secrets.usecaseExistingSecretName | trunc 63 | trimSuffix "-" -}}
20+
{{- else -}}
1821
{{- printf "%s-usecase-secret" .Release.Name | trunc 63 | trimSuffix "-" -}}
1922
{{- end -}}
23+
{{- end -}}
2024

2125
{{/* Resolve basic auth credentials from inline values or referenced secrets. */}}
2226
{{- define "rag.basicAuthCredentials" -}}

infrastructure/rag/templates/secrets.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ data:
99
S3_SECRET_ACCESS_KEY: {{ .Values.shared.secrets.s3.secretKey.value | b64enc }}
1010
{{- end }}
1111
---
12+
{{- if not .Values.shared.secrets.usecaseExistingSecretName }}
1213
apiVersion: v1
1314
kind: Secret
1415
metadata:
@@ -18,3 +19,4 @@ data:
1819
{{- range $key, $value := .Values.shared.secrets.usecase }}
1920
{{ $key }}: {{ $value | b64enc }}
2021
{{- end }}
22+
{{- end }}

infrastructure/rag/values.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,7 @@ shared:
531531
secretKeyRef:
532532
name: ""
533533
key: "S3_SECRET_ACCESS_KEY"
534+
usecaseExistingSecretName: "" # Optional: existing Secret name (e.g., from ESO). If set, chart will not create usecase secret.
534535
usecase: {}
535536

536537

0 commit comments

Comments
 (0)