secrets.yaml 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. {{- $name := .Chart.Name }}
  2. {{- $globalAnnotationsCheck := include "global.annotations.check" . }}
  3. {{- range $index, $val := .Values.items }}
  4. {{- if and $val.imagePullSecrets $val.imagePullSecrets.enabled $val.imagePullSecrets.data }}
  5. apiVersion: v1
  6. kind: Secret
  7. metadata:
  8. labels:
  9. app: {{ $name }}
  10. tier: {{ $val.name | default (print $name) }}-dockerconfig
  11. name: {{ $val.imagePullSecrets.name | default (print $name "-dockerconfig") }}
  12. type: {{ $val.imagePullSecrets.data.type | default (print "kubernetes.io/dockerconfigjson") }}
  13. data:
  14. {{- if and $val.imagePullSecrets.data.registry $val.imagePullSecrets.data.login $val.imagePullSecrets.data.password }}
  15. .dockerconfigjson: {{ printf "{\"auths\":{\"%v\":{\"auth\":\"%v\",\"password\":\"%v\",\"username\":\"%v\"}}}"
  16. $val.imagePullSecrets.data.registry (printf "%v:%v"
  17. $val.imagePullSecrets.data.login
  18. $val.imagePullSecrets.data.password | b64enc)
  19. $val.imagePullSecrets.data.password
  20. $val.imagePullSecrets.data.login | b64enc }}
  21. {{- else }}
  22. {{- with $val.imagePullSecrets.data }}{{- toYaml . | nindent 2 }}{{- end }}
  23. {{- end }}
  24. {{ print "---" }}
  25. {{- end }}{{- end }}
  26. {{- range $index, $val := .Values.items }}
  27. {{- if and $val.tls $val.tls.enabled $val.tls.data }}
  28. apiVersion: v1
  29. kind: Secret
  30. metadata:
  31. {{- if or $val.tls.annotations $globalAnnotationsCheck }}
  32. annotations:
  33. {{- if and $val.annotations (not (eq $val.type "global")) }}
  34. {{- toYaml $val.tls.annotations | nindent 4 }}
  35. {{- end }}
  36. {{- if $globalAnnotationsCheck }}
  37. {{- range $Index, $Val := $.Values.items }}
  38. {{- if eq $Val.type "global" }}
  39. {{- toYaml $Val.annotations | nindent 4 }}
  40. {{- end }}{{- end }}{{- end }}
  41. {{- end }}
  42. labels:
  43. app: {{ $name }}
  44. tier: {{ $val.name | default (print $name) }}-secret-tls
  45. name: {{ $val.tls.name | default (print $name "-secret-tls") }}
  46. type: {{ $val.tls.data.type | default (print "kubernetes.io/tls") }}
  47. data:
  48. {{- if and $val.tls.data.key $val.tls.data.crt }}
  49. tls.key: {{ printf "%v" $val.tls.data.key | b64enc }}
  50. tls.crt: {{ printf "%v" $val.tls.data.crt | b64enc }}
  51. {{- else }}
  52. {{- with $val.tls.data }}{{- toYaml . | nindent 2 }}{{- end }}
  53. {{- end }}
  54. {{ print "---" }}
  55. {{- end }}{{- end }}
  56. {{- range $index, $val := .Values.items }}
  57. {{- if not (empty $val.containers) }}
  58. {{- range $Index, $Containers := $val.containers }}
  59. {{- if and $Containers.secret $Containers.secret.enabled $Containers.secret.data }}
  60. apiVersion: v1
  61. kind: Secret
  62. metadata:
  63. {{- if or $val.annotations $globalAnnotationsCheck }}
  64. annotations:
  65. {{- if and $val.annotations (not (eq $val.type "global")) }}
  66. {{- toYaml $val.annotations | nindent 4 }}
  67. {{- end }}
  68. {{- if $globalAnnotationsCheck }}
  69. {{- range $Index, $Val := $.Values.items }}
  70. {{- if eq $Val.type "global" }}
  71. {{- toYaml $Val.annotations | nindent 4 }}
  72. {{- end }}{{- end }}{{- end }}
  73. {{- end }}
  74. labels:
  75. app: {{ $name }}
  76. tier: {{ $val.name | default (print $name) }}-secret
  77. name: {{ $Containers.secret.name | default (print $name "-secret") }}
  78. type: Opaque
  79. data:
  80. {{- range $key, $value := $Containers.secret.data }}{{- if $value }}
  81. {{- printf "%v: %v" $key (printf "%v" $value | b64enc) | nindent 2 }}
  82. {{- end }}{{- end }}
  83. {{ print "---" }}
  84. {{- end }}{{- end }}{{- end }}{{- end }}