From 3a79ed838d719a2e05bee39aef44f5065c3cf535 Mon Sep 17 00:00:00 2001 From: Bertrand THOMAS Date: Tue, 27 Jan 2026 00:03:36 +0100 Subject: [PATCH] Add connstring secret for todoblazor --- charts/todoblazor/CONTRIBUTING.md | 20 ++++++++++++++++---- charts/todoblazor/templates/deployment.yaml | 12 ++++++++++++ charts/todoblazor/values.yaml | 6 +++++- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/charts/todoblazor/CONTRIBUTING.md b/charts/todoblazor/CONTRIBUTING.md index 056e443..2105a8e 100644 --- a/charts/todoblazor/CONTRIBUTING.md +++ b/charts/todoblazor/CONTRIBUTING.md @@ -25,15 +25,27 @@ helm dependency update ## Validate on a test cluster +Create the secret with the connection string: + +```bash +kubectl create ns demo +kubectl create secret generic todoblazor-database \ + --from-literal=connectionstring='mongodb://root:admin@todoblazor-mongodb:27017/todolist?authSource=admin' \ + --namespace demo +``` + Create a `values.mine.yaml` file: ```yaml dotnet: environment: Development - enableOpenTelemetry: false webapp: + tag: 1.0.21375563304 db: - connectionString: mongodb://root:admin@todoblazor-mongodb:27017/todolist?authSource=admin + # connectionString: mongodb://root:admin@todoblazor-mongodb:27017/todolist?authSource=admin + connectionStringSecretKeyRef: + name: todoblazor-database + key: connectionstring databaseName: todolist ingress: enabled: true @@ -52,7 +64,7 @@ Install or update the application: helm upgrade --install todoblazor . \ -f values.yaml -f values.mine.yaml \ --set webapp.host=todoblazor.console.$SANDBOX_ID.instruqt.io \ - --namespace demo --create-namespace + --namespace demo ``` Check everything is ok in the namespace: @@ -64,7 +76,7 @@ kubectl get pod,svc,deploy,rs,ingress,secret,pvc -n demo Open the web application in a browser: ```bash -echo https://todoblazor.console.$SANDBOX_ID.instruqt.io/swagger +echo https://todoblazor.console.$SANDBOX_ID.instruqt.io ``` If needed, debug with: diff --git a/charts/todoblazor/templates/deployment.yaml b/charts/todoblazor/templates/deployment.yaml index 11b34ee..1c3f0c2 100644 --- a/charts/todoblazor/templates/deployment.yaml +++ b/charts/todoblazor/templates/deployment.yaml @@ -81,9 +81,21 @@ spec: - name: OpenTelemetry__CollectorEndpoint value: "http://$(HOST_IP):4317" {{- end }} + {{- if $.Values.dotnet.enableHttpRedirect }} + - name: Features__IsHttpsRedirectionEnabled + value: "true" + {{- end }} {{- if .db }} + {{- if .db.connectionStringSecretKeyRef }} + - name: DatabaseSettings__ConnectionString + valueFrom: + secretKeyRef: + name: {{ .db.connectionStringSecretKeyRef.name }} + key: {{ .db.connectionStringSecretKeyRef.key }} + {{- else }} - name: DatabaseSettings__ConnectionString value: {{ .db.connectionString }} + {{- end }} - name: DatabaseSettings__DatabaseName value: {{ .db.databaseName }} {{- end }} diff --git a/charts/todoblazor/values.yaml b/charts/todoblazor/values.yaml index 2cd76e1..ed73b57 100644 --- a/charts/todoblazor/values.yaml +++ b/charts/todoblazor/values.yaml @@ -10,7 +10,10 @@ containerPort: 8080 healthEndpoint: /health db: - connectionString: "someconnstring" + # connectionString: "someconnstring" + # connectionStringSecretKeyRef: + # name: todoblazor-secret + # key: db-connectionstring databaseName: "somedb" extraEnv: [] # - name: xxx @@ -33,6 +36,7 @@ dotnet: framework: Information application: Information enableOpenTelemetry: false + enableHttpRedirect: true ingress: enabled: false