secret.yaml 951 B

12345678910111213141516171819202122232425
  1. {{/* Use the bootstrap password from values.yaml if an existing secret is not found */}}
  2. {{- $bootstrapPassword := .Values.bootstrapPassword -}}
  3. {{- $existingSecret := lookup "v1" "Secret" .Release.Namespace "bootstrap-secret" -}}
  4. {{- if $existingSecret -}}
  5. {{- if $existingSecret.data -}}
  6. {{- if $existingSecret.data.bootstrapPassword -}}
  7. {{- $bootstrapPassword = $existingSecret.data.bootstrapPassword | b64dec -}}
  8. {{- end -}}
  9. {{- end -}}
  10. {{- end -}}
  11. {{/* If a bootstrap password was found in the values or an existing password was found create the secret */}}
  12. {{- if $bootstrapPassword }}
  13. apiVersion: v1
  14. kind: Secret
  15. metadata:
  16. name: "bootstrap-secret"
  17. namespace: {{ .Release.Namespace }}
  18. annotations:
  19. "helm.sh/hook": pre-install,pre-upgrade
  20. "helm.sh/hook-weight": "-5"
  21. "helm.sh/resource-policy": keep
  22. type: Opaque
  23. data:
  24. bootstrapPassword: {{ $bootstrapPassword | b64enc | quote }}
  25. {{- end }}