_helpers.tpl 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. {{/* vim: set filetype=mustache: */}}
  2. {{/*
  3. Expand the name of the chart.
  4. */}}
  5. {{- define "docker-registry.name" -}}
  6. {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
  7. {{- end -}}
  8. {{/*
  9. Create a default fully qualified app name.
  10. We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
  11. */}}
  12. {{- define "docker-registry.fullname" -}}
  13. {{- if .Values.fullnameOverride -}}
  14. {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
  15. {{- else -}}
  16. {{- $name := default .Chart.Name .Values.nameOverride -}}
  17. {{- if contains $name .Release.Name -}}
  18. {{- .Release.Name | trunc 63 | trimSuffix "-" -}}
  19. {{- else -}}
  20. {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
  21. {{- end -}}
  22. {{- end -}}
  23. {{- end -}}
  24. {{- define "docker-registry.envs" -}}
  25. - name: REGISTRY_HTTP_SECRET
  26. valueFrom:
  27. secretKeyRef:
  28. name: {{ template "docker-registry.fullname" . }}-secret
  29. key: haSharedSecret
  30. {{- if .Values.secrets.htpasswd }}
  31. - name: REGISTRY_AUTH
  32. value: "htpasswd"
  33. - name: REGISTRY_AUTH_HTPASSWD_REALM
  34. value: "Registry Realm"
  35. - name: REGISTRY_AUTH_HTPASSWD_PATH
  36. value: "/auth/htpasswd"
  37. {{- end }}
  38. {{- if .Values.tlsSecretName }}
  39. - name: REGISTRY_HTTP_TLS_CERTIFICATE
  40. value: /etc/ssl/docker/tls.crt
  41. - name: REGISTRY_HTTP_TLS_KEY
  42. value: /etc/ssl/docker/tls.key
  43. {{- end -}}
  44. {{- if eq .Values.storage "filesystem" }}
  45. - name: REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY
  46. value: "/var/lib/registry"
  47. {{- else if eq .Values.storage "azure" }}
  48. - name: REGISTRY_STORAGE_AZURE_ACCOUNTNAME
  49. valueFrom:
  50. secretKeyRef:
  51. name: {{ template "docker-registry.fullname" . }}-secret
  52. key: azureAccountName
  53. - name: REGISTRY_STORAGE_AZURE_ACCOUNTKEY
  54. valueFrom:
  55. secretKeyRef:
  56. name: {{ template "docker-registry.fullname" . }}-secret
  57. key: azureAccountKey
  58. - name: REGISTRY_STORAGE_AZURE_CONTAINER
  59. valueFrom:
  60. secretKeyRef:
  61. name: {{ template "docker-registry.fullname" . }}-secret
  62. key: azureContainer
  63. {{- else if eq .Values.storage "s3" }}
  64. - name: REGISTRY_STORAGE_S3_REGION
  65. value: {{ required ".Values.s3.region is required" .Values.s3.region }}
  66. - name: REGISTRY_STORAGE_S3_BUCKET
  67. value: {{ required ".Values.s3.bucket is required" .Values.s3.bucket }}
  68. {{- if or (and .Values.secrets.s3.secretKey .Values.secrets.s3.accessKey) .Values.secrets.s3.secretRef }}
  69. - name: REGISTRY_STORAGE_S3_ACCESSKEY
  70. valueFrom:
  71. secretKeyRef:
  72. name: {{ if .Values.secrets.s3.secretRef }}{{ .Values.secrets.s3.secretRef }}{{ else }}{{ template "docker-registry.fullname" . }}-secret{{ end }}
  73. key: s3AccessKey
  74. - name: REGISTRY_STORAGE_S3_SECRETKEY
  75. valueFrom:
  76. secretKeyRef:
  77. name: {{ if .Values.secrets.s3.secretRef }}{{ .Values.secrets.s3.secretRef }}{{ else }}{{ template "docker-registry.fullname" . }}-secret{{ end }}
  78. key: s3SecretKey
  79. {{- end -}}
  80. {{- if .Values.s3.regionEndpoint }}
  81. - name: REGISTRY_STORAGE_S3_REGIONENDPOINT
  82. value: {{ .Values.s3.regionEndpoint }}
  83. {{- end -}}
  84. {{- if .Values.s3.rootdirectory }}
  85. - name: REGISTRY_STORAGE_S3_ROOTDIRECTORY
  86. value: {{ .Values.s3.rootdirectory | quote }}
  87. {{- end -}}
  88. {{- if .Values.s3.encrypt }}
  89. - name: REGISTRY_STORAGE_S3_ENCRYPT
  90. value: {{ .Values.s3.encrypt | quote }}
  91. {{- end -}}
  92. {{- if .Values.s3.secure }}
  93. - name: REGISTRY_STORAGE_S3_SECURE
  94. value: {{ .Values.s3.secure | quote }}
  95. {{- end -}}
  96. {{- else if eq .Values.storage "swift" }}
  97. - name: REGISTRY_STORAGE_SWIFT_AUTHURL
  98. value: {{ required ".Values.swift.authurl is required" .Values.swift.authurl }}
  99. - name: REGISTRY_STORAGE_SWIFT_USERNAME
  100. valueFrom:
  101. secretKeyRef:
  102. name: {{ template "docker-registry.fullname" . }}-secret
  103. key: swiftUsername
  104. - name: REGISTRY_STORAGE_SWIFT_PASSWORD
  105. valueFrom:
  106. secretKeyRef:
  107. name: {{ template "docker-registry.fullname" . }}-secret
  108. key: swiftPassword
  109. - name: REGISTRY_STORAGE_SWIFT_CONTAINER
  110. value: {{ required ".Values.swift.container is required" .Values.swift.container }}
  111. {{- end -}}
  112. {{- if .Values.proxy.enabled }}
  113. - name: REGISTRY_PROXY_REMOTEURL
  114. value: {{ required ".Values.proxy.remoteurl is required" .Values.proxy.remoteurl }}
  115. - name: REGISTRY_PROXY_USERNAME
  116. valueFrom:
  117. secretKeyRef:
  118. name: {{ if .Values.proxy.secretRef }}{{ .Values.proxy.secretRef }}{{ else }}{{ template "docker-registry.fullname" . }}-secret{{ end }}
  119. key: proxyUsername
  120. - name: REGISTRY_PROXY_PASSWORD
  121. valueFrom:
  122. secretKeyRef:
  123. name: {{ if .Values.proxy.secretRef }}{{ .Values.proxy.secretRef }}{{ else }}{{ template "docker-registry.fullname" . }}-secret{{ end }}
  124. key: proxyPassword
  125. {{- end -}}
  126. {{- if .Values.persistence.deleteEnabled }}
  127. - name: REGISTRY_STORAGE_DELETE_ENABLED
  128. value: "true"
  129. {{- end -}}
  130. {{- with .Values.extraEnvVars }}
  131. {{ toYaml . }}
  132. {{- end -}}
  133. {{- end -}}
  134. {{- define "docker-registry.volumeMounts" -}}
  135. - name: "{{ template "docker-registry.fullname" . }}-config"
  136. mountPath: "/etc/docker/registry"
  137. {{- if .Values.secrets.htpasswd }}
  138. - name: auth
  139. mountPath: /auth
  140. readOnly: true
  141. {{- end }}
  142. {{- if eq .Values.storage "filesystem" }}
  143. - name: data
  144. mountPath: /var/lib/registry/
  145. {{- end }}
  146. {{- if .Values.tlsSecretName }}
  147. - mountPath: /etc/ssl/docker
  148. name: tls-cert
  149. readOnly: true
  150. {{- end }}
  151. {{- with .Values.extraVolumeMounts }}
  152. {{ toYaml . }}
  153. {{- end }}
  154. {{- end -}}
  155. {{- define "docker-registry.volumes" -}}
  156. - name: {{ template "docker-registry.fullname" . }}-config
  157. configMap:
  158. name: {{ template "docker-registry.fullname" . }}-config
  159. {{- if .Values.secrets.htpasswd }}
  160. - name: auth
  161. secret:
  162. secretName: {{ template "docker-registry.fullname" . }}-secret
  163. items:
  164. - key: htpasswd
  165. path: htpasswd
  166. {{- end }}
  167. {{- if eq .Values.storage "filesystem" }}
  168. - name: data
  169. {{- if .Values.persistence.enabled }}
  170. persistentVolumeClaim:
  171. claimName: {{ if .Values.persistence.existingClaim }}{{ .Values.persistence.existingClaim }}{{- else }}{{ template "docker-registry.fullname" . }}{{- end }}
  172. {{- else }}
  173. emptyDir: {}
  174. {{- end -}}
  175. {{- end }}
  176. {{- if .Values.tlsSecretName }}
  177. - name: tls-cert
  178. secret:
  179. secretName: {{ .Values.tlsSecretName }}
  180. {{- end }}
  181. {{- with .Values.extraVolumes }}
  182. {{ toYaml . }}
  183. {{- end }}
  184. {{- end -}}