Skip to content

Commit 87faaf0

Browse files
authored
Set db connstring in secret for todoblazor (#47)
* Add connstring secret for todoblazor * Dump chart version
1 parent 861e0c7 commit 87faaf0

4 files changed

Lines changed: 34 additions & 6 deletions

File tree

charts/todoblazor/CONTRIBUTING.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,27 @@ helm dependency update
2525

2626
## Validate on a test cluster
2727

28+
Create the secret with the connection string:
29+
30+
```bash
31+
kubectl create ns demo
32+
kubectl create secret generic todoblazor-database \
33+
--from-literal=connectionstring='mongodb://root:admin@todoblazor-mongodb:27017/todolist?authSource=admin' \
34+
--namespace demo
35+
```
36+
2837
Create a `values.mine.yaml` file:
2938

3039
```yaml
3140
dotnet:
3241
environment: Development
33-
enableOpenTelemetry: false
3442
webapp:
43+
tag: 1.0.21375563304
3544
db:
36-
connectionString: mongodb://root:admin@todoblazor-mongodb:27017/todolist?authSource=admin
45+
# connectionString: mongodb://root:admin@todoblazor-mongodb:27017/todolist?authSource=admin
46+
connectionStringSecretKeyRef:
47+
name: todoblazor-database
48+
key: connectionstring
3749
databaseName: todolist
3850
ingress:
3951
enabled: true
@@ -52,7 +64,7 @@ Install or update the application:
5264
helm upgrade --install todoblazor . \
5365
-f values.yaml -f values.mine.yaml \
5466
--set webapp.host=todoblazor.console.$SANDBOX_ID.instruqt.io \
55-
--namespace demo --create-namespace
67+
--namespace demo
5668
```
5769

5870
Check everything is ok in the namespace:
@@ -64,7 +76,7 @@ kubectl get pod,svc,deploy,rs,ingress,secret,pvc -n demo
6476
Open the web application in a browser:
6577

6678
```bash
67-
echo https://todoblazor.console.$SANDBOX_ID.instruqt.io/swagger
79+
echo https://todoblazor.console.$SANDBOX_ID.instruqt.io
6880
```
6981

7082
If needed, debug with:

charts/todoblazor/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name: todoblazor
33
description: Helm chart for Todo Blazor web application
44
type: application
5-
version: 0.1.0
5+
version: 0.1.1
66
appVersion: "1.0.0"
77
dependencies:
88
- name: mongodb

charts/todoblazor/templates/deployment.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,21 @@ spec:
8181
- name: OpenTelemetry__CollectorEndpoint
8282
value: "http://$(HOST_IP):4317"
8383
{{- end }}
84+
{{- if $.Values.dotnet.enableHttpRedirect }}
85+
- name: Features__IsHttpsRedirectionEnabled
86+
value: "true"
87+
{{- end }}
8488
{{- if .db }}
89+
{{- if .db.connectionStringSecretKeyRef }}
90+
- name: DatabaseSettings__ConnectionString
91+
valueFrom:
92+
secretKeyRef:
93+
name: {{ .db.connectionStringSecretKeyRef.name }}
94+
key: {{ .db.connectionStringSecretKeyRef.key }}
95+
{{- else }}
8596
- name: DatabaseSettings__ConnectionString
8697
value: {{ .db.connectionString }}
98+
{{- end }}
8799
- name: DatabaseSettings__DatabaseName
88100
value: {{ .db.databaseName }}
89101
{{- end }}

charts/todoblazor/values.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
containerPort: 8080
1111
healthEndpoint: /health
1212
db:
13-
connectionString: "someconnstring"
13+
# connectionString: "someconnstring"
14+
# connectionStringSecretKeyRef:
15+
# name: todoblazor-secret
16+
# key: db-connectionstring
1417
databaseName: "somedb"
1518
extraEnv: []
1619
# - name: xxx
@@ -33,6 +36,7 @@ dotnet:
3336
framework: Information
3437
application: Information
3538
enableOpenTelemetry: false
39+
enableHttpRedirect: true
3640

3741
ingress:
3842
enabled: false

0 commit comments

Comments
 (0)