core-dpl.yaml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. apiVersion: apps/v1
  2. kind: Deployment
  3. metadata:
  4. name: {{ template "harbor.core" . }}
  5. namespace: {{ .Release.Namespace | quote }}
  6. labels:
  7. {{ include "harbor.labels" . | indent 4 }}
  8. component: core
  9. app.kubernetes.io/component: core
  10. spec:
  11. replicas: {{ .Values.core.replicas }}
  12. revisionHistoryLimit: {{ .Values.core.revisionHistoryLimit }}
  13. selector:
  14. matchLabels:
  15. {{ include "harbor.matchLabels" . | indent 6 }}
  16. component: core
  17. template:
  18. metadata:
  19. labels:
  20. {{ include "harbor.labels" . | indent 8 }}
  21. component: core
  22. app.kubernetes.io/component: core
  23. {{- if .Values.core.podLabels }}
  24. {{ toYaml .Values.core.podLabels | indent 8 }}
  25. {{- end }}
  26. annotations:
  27. checksum/configmap: {{ include (print $.Template.BasePath "/core/core-cm.yaml") . | sha256sum }}
  28. checksum/secret: {{ include (print $.Template.BasePath "/core/core-secret.yaml") . | sha256sum }}
  29. checksum/secret-jobservice: {{ include (print $.Template.BasePath "/jobservice/jobservice-secrets.yaml") . | sha256sum }}
  30. {{- if and .Values.internalTLS.enabled (eq .Values.internalTLS.certSource "auto") }}
  31. checksum/tls: {{ include (print $.Template.BasePath "/internal/auto-tls.yaml") . | sha256sum }}
  32. {{- else if and .Values.internalTLS.enabled (eq .Values.internalTLS.certSource "manual") }}
  33. checksum/tls: {{ include (print $.Template.BasePath "/core/core-tls.yaml") . | sha256sum }}
  34. {{- end }}
  35. {{- if .Values.core.podAnnotations }}
  36. {{ toYaml .Values.core.podAnnotations | indent 8 }}
  37. {{- end }}
  38. spec:
  39. securityContext:
  40. runAsUser: 10000
  41. fsGroup: 10000
  42. {{- if .Values.core.serviceAccountName }}
  43. serviceAccountName: {{ .Values.core.serviceAccountName }}
  44. {{- end -}}
  45. {{- with .Values.imagePullSecrets }}
  46. imagePullSecrets:
  47. {{- toYaml . | nindent 8 }}
  48. {{- end }}
  49. automountServiceAccountToken: {{ .Values.core.automountServiceAccountToken | default false }}
  50. terminationGracePeriodSeconds: 120
  51. {{- with .Values.core.topologySpreadConstraints}}
  52. topologySpreadConstraints:
  53. {{- range . }}
  54. - {{ . | toYaml | indent 8 | trim }}
  55. labelSelector:
  56. matchLabels:
  57. {{ include "harbor.matchLabels" $ | indent 12 }}
  58. component: core
  59. {{- end }}
  60. {{- end }}
  61. {{- with .Values.core.initContainers }}
  62. initContainers:
  63. {{- toYaml . | nindent 8 }}
  64. {{- end }}
  65. containers:
  66. - name: core
  67. image: {{ .Values.core.image.repository }}:{{ .Values.core.image.tag }}
  68. imagePullPolicy: {{ .Values.imagePullPolicy }}
  69. {{- if .Values.core.startupProbe.enabled }}
  70. startupProbe:
  71. httpGet:
  72. path: /api/v2.0/ping
  73. scheme: {{ include "harbor.component.scheme" . | upper }}
  74. port: {{ template "harbor.core.containerPort" . }}
  75. initialDelaySeconds: {{ .Values.core.startupProbe.initialDelaySeconds }}
  76. periodSeconds: {{ .Values.core.startupProbe.periodSeconds }}
  77. timeoutSeconds: {{ .Values.core.startupProbe.timeoutSeconds }}
  78. failureThreshold: {{ .Values.core.startupProbe.failureThreshold }}
  79. successThreshold: {{ .Values.core.startupProbe.successThreshold }}
  80. {{- end }}
  81. livenessProbe:
  82. httpGet:
  83. path: /api/v2.0/ping
  84. scheme: {{ include "harbor.component.scheme" . | upper }}
  85. port: {{ template "harbor.core.containerPort" . }}
  86. initialDelaySeconds: {{ .Values.core.livenessProbe.initialDelaySeconds }}
  87. periodSeconds: {{ .Values.core.livenessProbe.periodSeconds }}
  88. timeoutSeconds: {{ .Values.core.livenessProbe.timeoutSeconds }}
  89. failureThreshold: {{ .Values.core.livenessProbe.failureThreshold }}
  90. successThreshold: {{ .Values.core.livenessProbe.successThreshold }}
  91. readinessProbe:
  92. httpGet:
  93. path: /api/v2.0/ping
  94. scheme: {{ include "harbor.component.scheme" . | upper }}
  95. port: {{ template "harbor.core.containerPort" . }}
  96. initialDelaySeconds: {{ .Values.core.readinessProbe.initialDelaySeconds }}
  97. periodSeconds: {{ .Values.core.readinessProbe.periodSeconds }}
  98. timeoutSeconds: {{ .Values.core.readinessProbe.timeoutSeconds }}
  99. failureThreshold: {{ .Values.core.readinessProbe.failureThreshold }}
  100. successThreshold: {{ .Values.core.readinessProbe.successThreshold }}
  101. envFrom:
  102. - configMapRef:
  103. name: "{{ template "harbor.core" . }}"
  104. - secretRef:
  105. name: "{{ template "harbor.core" . }}"
  106. env:
  107. - name: CORE_SECRET
  108. valueFrom:
  109. secretKeyRef:
  110. name: {{ default (include "harbor.core" .) .Values.core.existingSecret }}
  111. key: secret
  112. - name: JOBSERVICE_SECRET
  113. valueFrom:
  114. secretKeyRef:
  115. name: {{ default (include "harbor.jobservice" .) .Values.jobservice.existingSecret }}
  116. {{- if .Values.jobservice.existingSecret }}
  117. key: {{ .Values.jobservice.existingSecretKey }}
  118. {{- else }}
  119. key: JOBSERVICE_SECRET
  120. {{- end }}
  121. {{- if .Values.existingSecretAdminPassword }}
  122. - name: HARBOR_ADMIN_PASSWORD
  123. valueFrom:
  124. secretKeyRef:
  125. name: {{ .Values.existingSecretAdminPassword }}
  126. key: {{ .Values.existingSecretAdminPasswordKey }}
  127. {{- end }}
  128. {{- if .Values.internalTLS.enabled }}
  129. - name: INTERNAL_TLS_ENABLED
  130. value: "true"
  131. - name: INTERNAL_TLS_KEY_PATH
  132. value: /etc/harbor/ssl/core/tls.key
  133. - name: INTERNAL_TLS_CERT_PATH
  134. value: /etc/harbor/ssl/core/tls.crt
  135. - name: INTERNAL_TLS_TRUST_CA_PATH
  136. value: /etc/harbor/ssl/core/ca.crt
  137. {{- end }}
  138. {{- if .Values.database.external.existingSecret }}
  139. - name: POSTGRESQL_PASSWORD
  140. valueFrom:
  141. secretKeyRef:
  142. name: {{ .Values.database.external.existingSecret }}
  143. key: password
  144. {{- end }}
  145. {{- if .Values.registry.credentials.existingSecret }}
  146. - name: REGISTRY_CREDENTIAL_PASSWORD
  147. valueFrom:
  148. secretKeyRef:
  149. name: {{ .Values.registry.credentials.existingSecret }}
  150. key: REGISTRY_PASSWD
  151. {{- end }}
  152. {{- if .Values.core.existingXsrfSecret }}
  153. - name: CSRF_KEY
  154. valueFrom:
  155. secretKeyRef:
  156. name: {{ .Values.core.existingXsrfSecret }}
  157. key: {{ .Values.core.existingXsrfSecretKey }}
  158. {{- end }}
  159. {{- with .Values.core.extraEnvVars }}
  160. {{- toYaml . | nindent 10 }}
  161. {{- end }}
  162. {{- if not (empty .Values.containerSecurityContext) }}
  163. securityContext: {{ .Values.containerSecurityContext | toYaml | nindent 10 }}
  164. {{- end }}
  165. ports:
  166. - containerPort: {{ template "harbor.core.containerPort" . }}
  167. volumeMounts:
  168. - name: config
  169. mountPath: /etc/core/app.conf
  170. subPath: app.conf
  171. - name: secret-key
  172. mountPath: /etc/core/key
  173. subPath: key
  174. - name: token-service-private-key
  175. mountPath: /etc/core/private_key.pem
  176. subPath: tls.key
  177. {{- if .Values.expose.tls.enabled }}
  178. - name: ca-download
  179. mountPath: /etc/core/ca
  180. {{- end }}
  181. {{- if .Values.uaaSecretName }}
  182. - name: auth-ca-cert
  183. mountPath: /etc/core/auth-ca/auth-ca.crt
  184. subPath: auth-ca.crt
  185. {{- end }}
  186. {{- if .Values.internalTLS.enabled }}
  187. - name: core-internal-certs
  188. mountPath: /etc/harbor/ssl/core
  189. {{- end }}
  190. - name: psc
  191. mountPath: /etc/core/token
  192. {{- if .Values.caBundleSecretName }}
  193. {{ include "harbor.caBundleVolumeMount" . | indent 8 }}
  194. {{- end }}
  195. {{- if .Values.core.resources }}
  196. resources:
  197. {{ toYaml .Values.core.resources | indent 10 }}
  198. {{- end }}
  199. volumes:
  200. - name: config
  201. configMap:
  202. name: {{ template "harbor.core" . }}
  203. items:
  204. - key: app.conf
  205. path: app.conf
  206. - name: secret-key
  207. secret:
  208. {{- if .Values.existingSecretSecretKey }}
  209. secretName: {{ .Values.existingSecretSecretKey }}
  210. {{- else }}
  211. secretName: {{ template "harbor.core" . }}
  212. {{- end }}
  213. items:
  214. - key: secretKey
  215. path: key
  216. - name: token-service-private-key
  217. secret:
  218. {{- if .Values.core.secretName }}
  219. secretName: {{ .Values.core.secretName }}
  220. {{- else }}
  221. secretName: {{ template "harbor.core" . }}
  222. {{- end }}
  223. {{- if .Values.expose.tls.enabled }}
  224. - name: ca-download
  225. secret:
  226. {{- if .Values.caSecretName }}
  227. secretName: {{ .Values.caSecretName }}
  228. {{- else if eq (include "harbor.autoGenCertForIngress" .) "true" }}
  229. secretName: "{{ template "harbor.ingress" . }}"
  230. {{- else if eq (include "harbor.autoGenCertForNginx" .) "true" }}
  231. secretName: {{ template "harbor.tlsSecretForNginx" . }}
  232. {{- end }}
  233. {{- end }}
  234. {{- if .Values.uaaSecretName }}
  235. - name: auth-ca-cert
  236. secret:
  237. secretName: {{ .Values.uaaSecretName }}
  238. items:
  239. - key: ca.crt
  240. path: auth-ca.crt
  241. {{- end }}
  242. {{- if .Values.internalTLS.enabled }}
  243. - name: core-internal-certs
  244. secret:
  245. secretName: {{ template "harbor.internalTLS.core.secretName" . }}
  246. {{- end }}
  247. - name: psc
  248. emptyDir: {}
  249. {{- if .Values.caBundleSecretName }}
  250. {{ include "harbor.caBundleVolume" . | indent 6 }}
  251. {{- end }}
  252. {{- with .Values.core.nodeSelector }}
  253. nodeSelector:
  254. {{ toYaml . | indent 8 }}
  255. {{- end }}
  256. {{- with .Values.core.affinity }}
  257. affinity:
  258. {{ toYaml . | indent 8 }}
  259. {{- end }}
  260. {{- with .Values.core.tolerations }}
  261. tolerations:
  262. {{ toYaml . | indent 8 }}
  263. {{- end }}
  264. {{- if .Values.core.priorityClassName }}
  265. priorityClassName: {{ .Values.core.priorityClassName }}
  266. {{- end }}