Skip to content

Commit f431bbc

Browse files
committed
CH-232 support cross-application secrets
1 parent ad54713 commit f431bbc

8 files changed

Lines changed: 244 additions & 707 deletions

File tree

application-templates/django-fastapi/backend/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Python >= 3
1515
# store the accounts api admin password on the local disk
1616
1717
mkdir -p /opt/cloudharness/resources/auth/
18-
kubectl -n mnp get secrets accounts -o yaml|grep api_user_password|cut -d " " -f 4|base64 -d > /opt/cloudharness/resources/auth/api_user_password
18+
kubectl -n mnp get secrets accounts -o yaml|grep api_user_password|cut -d " " -f 4|base64 -d > /opt/cloudharness/resources/accounts/api_user_password
1919
2020
# Make the cloudharness application configuration available on your local machine
2121
cp deployment/helm/values.yaml /opt/cloudharness/resources/allvalues.yaml

applications/accounts/scripts/create_api_user.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
#!/bin/bash
22

33
export API_USERNAME="admin_api"
4-
export API_PASSWORD=$(cat /opt/cloudharness/resources/auth/api_user_password 2>/dev/null || echo "")
4+
export API_PASSWORD=$(cat /opt/cloudharness/resources/accounts/api_user_password 2>/dev/null || echo "")
55
export TMP_CLIENT="tmp_api_client"
66
export TMP_CLIENT_SECRET="${KC_BOOTSTRAP_ADMIN_USERNAME}"
7+
export ACCOUNTS_SERVICE_PORT=8080
78

89
check_kc_ready() {
910
if echo >/dev/tcp/127.0.0.1/${ACCOUNTS_SERVICE_PORT}; then

deployment-configuration/helm/templates/_helpers.tpl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,8 @@ Create chart name and version as used by the chart label.
1010
For custom images: if images are coming from local(e.g minikube) registry, image pull policy is "Never". Otherwise it is "IfNotPresent"
1111
*/}}
1212
{{- define "deploy_utils.pullpolicy" -}}
13-
{{- if and .Values.local (not .Values.registry.name) -}}
14-
{{- print "Never" -}}
15-
{{- else -}}
1613
{{- print "IfNotPresent" -}}
1714
{{- end -}}
18-
{{- end -}}
1915
{{/*
2016
Add environmental variables to all containers
2117
*/}}

deployment-configuration/helm/templates/auto-deployments.yaml

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,22 @@ spec:
112112
- name: cloudharness-allvalues
113113
mountPath: /opt/cloudharness/resources
114114
readOnly: true
115-
{{- if or (has "accounts" .app.harness.dependencies.hard) (eq .app.harness.name "accounts") }}
116-
- name: cloudharness-kc-accounts
115+
{{- $root := .root }}
116+
{{- range $dep := concat .app.harness.dependencies.hard .app.harness.dependencies.soft }}
117+
{{- $depApp := index $root.Values.apps $dep }}
118+
{{- if $depApp.harness.secrets }}
119+
- name: cloudharness-{{ $dep }}
120+
mountPath: /opt/cloudharness/resources/secrets/{{ $dep }}
121+
readOnly: true
122+
{{- end }}
123+
{{- if or (has "accounts" .app.harness.dependencies.hard) (eq .app.harness.name "accounts") }}
124+
{{/* legacy path for accounts auth resources mount */}}
125+
{{- if eq $dep "accounts" }}
126+
- name: cloudharness-accounts
117127
mountPath: /opt/cloudharness/resources/auth
118128
readOnly: true
119129
{{- end }}
130+
{{- end }}
120131
{{- if .app.harness.deployment.volume }}
121132
- name: {{ .app.harness.deployment.volume.name }}
122133
mountPath: {{ .app.harness.deployment.volume.mountpath }}
@@ -131,17 +142,21 @@ spec:
131142
{{- end}}
132143
{{- if .app.harness.secrets }}
133144
- name: secrets
134-
mountPath: "/opt/cloudharness/resources/secrets"
145+
mountPath: "/opt/cloudharness/resources/secrets/{{ .app.harness.name }}"
135146
readOnly: true
136147
{{- end }}
137148
volumes:
138149
- name: cloudharness-allvalues
139150
configMap:
140151
name: cloudharness-allvalues
141-
{{- if or (has "accounts" .app.harness.dependencies.hard) (eq .app.harness.name "accounts") }}
142-
- name: cloudharness-kc-accounts
152+
{{- $root := .root }}
153+
{{- range $dep := concat .app.harness.dependencies.hard .app.harness.dependencies.soft }}
154+
{{- $depApp := index $root.Values.apps $dep }}
155+
{{- if $depApp.harness.secrets }}
156+
- name: cloudharness-{{ $dep }}
143157
secret:
144-
secretName: accounts
158+
secretName: {{ $dep }}
159+
{{- end }}
145160
{{- end }}
146161
{{- if .app.harness.deployment.volume }}
147162
- name: {{ .app.harness.deployment.volume.name }}

0 commit comments

Comments
 (0)