registry-secret.yaml 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. {{- $existingSecret := lookup "v1" "Secret" .Release.Namespace (include "harbor.registry" .) }}
  2. apiVersion: v1
  3. kind: Secret
  4. metadata:
  5. name: "{{ template "harbor.registry" . }}"
  6. namespace: {{ .Release.Namespace | quote }}
  7. labels:
  8. {{ include "harbor.labels" . | indent 4 }}
  9. type: Opaque
  10. data:
  11. {{- if not .Values.registry.existingSecret }}
  12. REGISTRY_HTTP_SECRET: {{ .Values.registry.secret | default (include "harbor.secretKeyHelper" (dict "key" "REGISTRY_HTTP_SECRET" "data" $existingSecret.data)) | default (randAlphaNum 16) | b64enc | quote }}
  13. {{- end }}
  14. {{- if not .Values.redis.external.existingSecret }}
  15. REGISTRY_REDIS_PASSWORD: {{ include "harbor.redis.password" . | b64enc | quote }}
  16. {{- end }}
  17. {{- $storage := .Values.persistence.imageChartStorage }}
  18. {{- $type := $storage.type }}
  19. {{- if and (eq $type "azure") (not $storage.azure.existingSecret) }}
  20. REGISTRY_STORAGE_AZURE_ACCOUNTKEY: {{ $storage.azure.accountkey | b64enc | quote }}
  21. {{- else if and (and (eq $type "gcs") (not $storage.gcs.existingSecret)) (not $storage.gcs.useWorkloadIdentity) }}
  22. GCS_KEY_DATA: {{ $storage.gcs.encodedkey | quote }}
  23. {{- else if eq $type "s3" }}
  24. {{- if and (not $storage.s3.existingSecret) ($storage.s3.accesskey) }}
  25. REGISTRY_STORAGE_S3_ACCESSKEY: {{ $storage.s3.accesskey | b64enc | quote }}
  26. {{- end }}
  27. {{- if and (not $storage.s3.existingSecret) ($storage.s3.secretkey) }}
  28. REGISTRY_STORAGE_S3_SECRETKEY: {{ $storage.s3.secretkey | b64enc | quote }}
  29. {{- end }}
  30. {{- else if and (eq $type "swift") (not ($storage.swift.existingSecret)) }}
  31. REGISTRY_STORAGE_SWIFT_PASSWORD: {{ $storage.swift.password | b64enc | quote }}
  32. {{- if $storage.swift.secretkey }}
  33. REGISTRY_STORAGE_SWIFT_SECRETKEY: {{ $storage.swift.secretkey | b64enc | quote }}
  34. {{- end }}
  35. {{- if $storage.swift.accesskey }}
  36. REGISTRY_STORAGE_SWIFT_ACCESSKEY: {{ $storage.swift.accesskey | b64enc | quote }}
  37. {{- end }}
  38. {{- else if and (eq $type "oss") ((not ($storage.oss.existingSecret))) }}
  39. REGISTRY_STORAGE_OSS_ACCESSKEYSECRET: {{ $storage.oss.accesskeysecret | b64enc | quote }}
  40. {{- end }}
  41. {{- if not .Values.registry.credentials.existingSecret }}
  42. ---
  43. apiVersion: v1
  44. kind: Secret
  45. metadata:
  46. name: "{{ template "harbor.registry" . }}-htpasswd"
  47. namespace: {{ .Release.Namespace | quote }}
  48. labels:
  49. {{ include "harbor.labels" . | indent 4 }}
  50. type: Opaque
  51. data:
  52. {{- if .Values.registry.credentials.htpasswdString }}
  53. REGISTRY_HTPASSWD: {{ .Values.registry.credentials.htpasswdString | b64enc | quote }}
  54. {{- else }}
  55. REGISTRY_HTPASSWD: {{ htpasswd .Values.registry.credentials.username .Values.registry.credentials.password | b64enc | quote }}
  56. {{- end }}
  57. {{- end }}