Skip to content
This repository has been archived by the owner on Oct 22, 2021. It is now read-only.

fix: use correct secret name when credentials are overridden #1671

Merged
merged 1 commit into from
Jan 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions chart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,27 @@ app.kubernetes.io/version: {{ default $root.Chart.Version $root.Chart.AppVersion
helm.sh/chart: {{ include "kubecf.chart" $root }}
{{- end }}

{{- /*
==========================================================================================
| kubecf.varSecretName (list $ $var_name)
+-----------------------------------------------------------------------------------------
| Returns the name of the kube secret for $var_name. This is normally the variable name
| prefixed with "var-", unless the value is overridden via $.Values.credentials, in which
| case it is prefixed with `cred-`.
==========================================================================================
*/ -}}
{{- define "kubecf.varSecretName" }}
{{- $root := first . }}
{{- $var_name := index . 1 }}
{{- $prefix := "var" }}
{{- range $name, $value := $root.Values.credentials }}
jandubois marked this conversation as resolved.
Show resolved Hide resolved
{{- if eq $var_name (splitList "." $name | first) }}
{{- $prefix = "cred" }}
{{- end }}
{{- end }}
{{- printf "%s-%s" $prefix $var_name | replace "_" "-" }}
jandubois marked this conversation as resolved.
Show resolved Hide resolved
{{- end }}

{{- /*
==========================================================================================
| Add imagePullSecrets to service accounts.
Expand Down
2 changes: 1 addition & 1 deletion chart/templates/apps_dns.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ spec:
emptyDir: {}
- name: client-tls
secret:
secretName: var-cf-app-sd-client-tls
secretName: {{ include "kubecf.varSecretName" (list $ "cf_app_sd_client_tls") }}
items:
- key: ca
path: ca.pem
Expand Down
2 changes: 1 addition & 1 deletion chart/templates/database/db-migrate-charset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ spec:
{{- range $secret := $.kubecf.databases }}
- name: {{ printf "%s-database-password" $secret | quote }}
secret:
secretName: {{ printf "var-%s-database-password" $secret | quote }}
secretName: {{ include "kubecf.varSecretName" (list $ (printf "%s_database_password" $secret)) }}
{{- end }}
restartPolicy: Never

Expand Down
4 changes: 2 additions & 2 deletions chart/templates/database/db-secrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ metadata:
{{- list . "database" | include "component.labels" | nindent 4 }}
spec:
type: password
secretName: var-pxc-root-password
secretName: {{ include "kubecf.varSecretName" (list $ "pxc_root_password") }}
---
apiVersion: quarks.cloudfoundry.org/v1alpha1
kind: QuarksSecret
Expand All @@ -21,6 +21,6 @@ metadata:
{{- list . "database" | include "component.labels" | nindent 4 }}
spec:
type: password
secretName: var-pxc-password
secretName: {{ include "kubecf.varSecretName" (list $ "pxc_password") }}

{{- end }}{{/* .Values.features.embedded_database.enabled */}}
2 changes: 1 addition & 1 deletion chart/templates/database/db-seeder.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ spec:
{{- range $secret := $.kubecf.databases }}
- name: {{ printf "%s-database-password" $secret | quote }}
secret:
secretName: {{ printf "var-%s-database-password" $secret | quote }}
secretName: {{ include "kubecf.varSecretName" (list $ (printf "%s_database_password" $secret)) }}
{{- end }}
restartPolicy: Never

Expand Down
2 changes: 1 addition & 1 deletion chart/templates/database/db-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ spec:
name: database-startup-scripts
- name: pxc-tls
secret:
secretName: var-pxc-tls
secretName: {{ include "kubecf.varSecretName" (list $ "pxc_tls") }}
volumeClaimTemplates:
- metadata:
name: pxc-data
Expand Down
26 changes: 13 additions & 13 deletions mixins/eirini/config/eirini.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@ eirini:
# The TLS secrets are generated by quarks-operator and should be HIDDEN from the user.
tls:
opiCapiClient:
secretName: "var-eirini-tls-client-cert"
secretName: {{ include "kubecf.varSecretName" (list $ "eirini_tls_client_cert") }}
keyPath: "private_key"
certPath: "certificate"
opiServer:
secretName: "var-eirini-tls-server-cert"
secretName: {{ include "kubecf.varSecretName" (list $ "eirini_tls_server_cert") }}
certPath: "certificate"
keyPath: "private_key"
capi:
secretName: "var-eirini-tls-server-cert"
secretName: {{ include "kubecf.varSecretName" (list $ "eirini_tls_server_cert") }}
caPath: "ca"
eirini:
secretName: "var-eirini-tls-server-cert"
secretName: {{ include "kubecf.varSecretName" (list $ "eirini_tls_server_cert") }}
caPath: "ca"

# components
Expand All @@ -54,11 +54,11 @@ eirini:
# here to adapt the Eirini helm chart for KubeCF use.
tls:
capiClient:
secretName: "var-cc-tls"
secretName: {{ include "kubecf.varSecretName" (list $ "cc_tls") }}
keyPath: "private_key"
certPath: "certificate"
capi:
secretName: "var-cc-tls"
secretName: {{ include "kubecf.varSecretName" (list $ "cc_tls") }}
caPath: "ca"

logs:
Expand All @@ -71,19 +71,19 @@ eirini:
enable: true
tls:
client:
secretName: "var-loggregator-tls-doppler"
secretName: {{ include "kubecf.varSecretName" (list $ "loggregator_tls_doppler") }}
keyPath: "private_key"
certPath: "certificate"
server:
secretName: "var-loggregator-tls-doppler"
secretName: {{ include "kubecf.varSecretName" (list $ "loggregator_tls_doppler") }}
caPath: "ca"

# All configs in this section should be HIDDEN from the user; they are here
# to adapt the Eirini helm chart for KubeCF use.
routing:
enable: true
nats:
secretName: "var-nats-password"
secretName: {{ include "kubecf.varSecretName" (list $ "nats_password") }}
passwordPath: "password"
serviceName: "nats"

Expand All @@ -100,18 +100,18 @@ eirini:
# The TLS secrets are generated by quarks-operator and should be HIDDEN from the user.
tls:
client:
secretName: "var-eirini-tls-client-cert"
secretName: {{ include "kubecf.varSecretName" (list $ "eirini_tls_client_cert") }}
certPath: "certificate"
keyPath: "private_key"
cc_uploader:
secretName: "var-cc-bridge-cc-uploader"
secretName: {{ include "kubecf.varSecretName" (list $ "cc_bridge_cc_uploader") }}
certPath: "certificate"
keyPath: "private_key"
ca:
secretName: "var-eirini-tls-client-cert"
secretName: {{ include "kubecf.varSecretName" (list $ "eirini_tls_client_cert") }}
path: "ca"
stagingReporter:
secretName: "var-eirini-tls-client-cert"
secretName: {{ include "kubecf.varSecretName" (list $ "eirini_tls_client_cert") }}
certPath: "certificate"
keyPath: "private_key"
caPath: "ca"