deployment.yaml 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. kind: Deployment
  2. apiVersion: apps/v1
  3. metadata:
  4. name: {{ template "rancher.fullname" . }}
  5. annotations:
  6. {{- if (lt (int .Values.replicas) 0) }}
  7. management.cattle.io/scale-available: "{{ sub 0 (int .Values.replicas)}}"
  8. {{- end }}
  9. labels:
  10. {{ include "rancher.labels" . | indent 4 }}
  11. spec:
  12. {{- if (gt (int .Values.replicas) 0) }}
  13. replicas: {{ .Values.replicas }}
  14. {{- end }}
  15. selector:
  16. matchLabels:
  17. app: {{ template "rancher.fullname" . }}
  18. strategy:
  19. rollingUpdate:
  20. maxSurge: 1
  21. {{- if (eq (int .Values.replicas) 1) }}
  22. maxUnavailable: 0
  23. {{- else }}
  24. maxUnavailable: 1
  25. {{- end }}
  26. type: RollingUpdate
  27. template:
  28. metadata:
  29. labels:
  30. app: {{ template "rancher.fullname" . }}
  31. release: {{ .Release.Name }}
  32. spec:
  33. priorityClassName: {{ .Values.priorityClassName }}
  34. serviceAccountName: {{ template "rancher.fullname" . }}
  35. {{- if .Values.imagePullSecrets }}
  36. imagePullSecrets:
  37. {{ toYaml .Values.imagePullSecrets | indent 6 }}
  38. {{- end }}
  39. affinity:
  40. podAntiAffinity:
  41. {{- if eq .Values.antiAffinity "required" }}
  42. requiredDuringSchedulingIgnoredDuringExecution:
  43. - labelSelector:
  44. matchExpressions:
  45. - key: app
  46. operator: In
  47. values:
  48. - {{ template "rancher.fullname" . }}
  49. topologyKey: {{ .Values.topologyKey | default "kubernetes.io/hostname" }}
  50. {{- else }}
  51. preferredDuringSchedulingIgnoredDuringExecution:
  52. - weight: 100
  53. podAffinityTerm:
  54. labelSelector:
  55. matchExpressions:
  56. - key: app
  57. operator: In
  58. values:
  59. - {{ template "rancher.fullname" . }}
  60. topologyKey: {{ .Values.topologyKey | default "kubernetes.io/hostname" }}
  61. {{- end }}
  62. nodeAffinity:
  63. requiredDuringSchedulingIgnoredDuringExecution:
  64. nodeSelectorTerms: {{ include "linux-node-selector-terms" . | nindent 14 }}
  65. tolerations: {{ include "linux-node-tolerations" . | nindent 8 }}
  66. containers:
  67. - image: {{ .Values.rancherImage }}:{{ default .Chart.AppVersion .Values.rancherImageTag }}
  68. imagePullPolicy: {{ default "IfNotPresent" .Values.rancherImagePullPolicy }}
  69. name: {{ template "rancher.name" . }}
  70. ports:
  71. - containerPort: 80
  72. protocol: TCP
  73. {{- if (and .Values.hostPort (gt (int .Values.hostPort) 0)) }}
  74. - containerPort: 444
  75. hostPort: {{ int .Values.hostPort }}
  76. protocol: TCP
  77. {{- end}}
  78. args:
  79. {{- if .Values.debug }}
  80. - "--debug"
  81. {{- end }}
  82. {{- if .Values.privateCA }}
  83. # Private CA - don't clear ca certs
  84. {{- else if and (eq .Values.tls "ingress") (eq .Values.ingress.tls.source "rancher") }}
  85. # Rancher self-signed - don't clear ca certs
  86. {{- else }}
  87. # Public trusted CA - clear ca certs
  88. - "--no-cacerts"
  89. {{- end }}
  90. - "--http-listen-port=80"
  91. - "--https-listen-port=443"
  92. - "--add-local={{ .Values.addLocal }}"
  93. env:
  94. - name: CATTLE_NAMESPACE
  95. value: {{ .Release.Namespace }}
  96. - name: CATTLE_PEER_SERVICE
  97. value: {{ template "rancher.fullname" . }}
  98. {{- if .Values.features }}
  99. - name: CATTLE_FEATURES
  100. value: "{{ .Values.features }}"
  101. {{- end}}
  102. {{- if .Values.noDefaultAdmin }}
  103. - name: CATTLE_NO_DEFAULT_ADMIN
  104. value: "{{ .Values.noDefaultAdmin }}"
  105. {{- end}}
  106. {{- if gt (int .Values.auditLog.level) 0 }}
  107. - name: AUDIT_LEVEL
  108. value: {{ .Values.auditLog.level | quote }}
  109. - name: AUDIT_LOG_MAXAGE
  110. value: {{ .Values.auditLog.maxAge | quote }}
  111. - name: AUDIT_LOG_MAXBACKUP
  112. value: {{ .Values.auditLog.maxBackup | quote }}
  113. - name: AUDIT_LOG_MAXSIZE
  114. value: {{ .Values.auditLog.maxSize | quote }}
  115. {{- end }}
  116. {{- if .Values.proxy }}
  117. - name: HTTP_PROXY
  118. value: {{ .Values.proxy }}
  119. - name: HTTPS_PROXY
  120. value: {{ .Values.proxy }}
  121. - name: NO_PROXY
  122. value: {{ .Values.noProxy }}
  123. {{- end }}
  124. {{- if .Values.systemDefaultRegistry }}
  125. - name: CATTLE_SYSTEM_DEFAULT_REGISTRY
  126. value: {{ .Values.systemDefaultRegistry }}
  127. {{- end }}
  128. {{- if .Values.useBundledSystemChart }}
  129. - name: CATTLE_SYSTEM_CATALOG
  130. value: bundled
  131. {{- end }}
  132. {{- if .Values.restrictedAdmin }}
  133. - name: CATTLE_RESTRICTED_DEFAULT_ADMIN
  134. value: "true"
  135. {{- end}}
  136. {{- if .Values.bootstrapPassword }}
  137. - name: CATTLE_BOOTSTRAP_PASSWORD
  138. valueFrom:
  139. secretKeyRef:
  140. name: "bootstrap-secret"
  141. key: "bootstrapPassword"
  142. {{- end }}
  143. {{- if .Values.extraEnv }}
  144. {{ toYaml .Values.extraEnv | indent 8}}
  145. {{- end }}
  146. livenessProbe:
  147. httpGet:
  148. path: /healthz
  149. port: 80
  150. initialDelaySeconds: 60
  151. periodSeconds: 30
  152. readinessProbe:
  153. httpGet:
  154. path: /healthz
  155. port: 80
  156. initialDelaySeconds: 5
  157. periodSeconds: 30
  158. resources:
  159. {{ toYaml .Values.resources | indent 10 }}
  160. volumeMounts:
  161. {{- if .Values.additionalTrustedCAs }}
  162. - mountPath: /etc/pki/trust/anchors/ca-additional.pem
  163. name: tls-ca-additional-volume
  164. subPath: ca-additional.pem
  165. readOnly: true
  166. - mountPath: /etc/rancher/ssl/ca-additional.pem
  167. name: tls-ca-additional-volume
  168. subPath: ca-additional.pem
  169. readOnly: true
  170. {{- end }}
  171. {{- if .Values.privateCA }}
  172. # Pass CA cert into rancher for private CA
  173. - mountPath: /etc/rancher/ssl/cacerts.pem
  174. name: tls-ca-volume
  175. subPath: cacerts.pem
  176. readOnly: true
  177. {{- end }}
  178. {{- if and .Values.customLogos.enabled (or (eq .Values.customLogos.volumeKind "persistentVolumeClaim") (and (eq .Values.customLogos.volumeKind "configMap") (.Values.customLogos.volumeName))) }}
  179. # Mount rancher custom-logos volume
  180. - mountPath: /usr/share/rancher/ui/assets/images/logos
  181. name: custom-logos
  182. subPath: {{ .Values.customLogos.volumeSubpaths.emberUi | default "ember" | quote }}
  183. - mountPath: /usr/share/rancher/ui-dashboard/dashboard/_nuxt/assets/images/pl
  184. name: custom-logos
  185. subPath: {{ .Values.customLogos.volumeSubpaths.vueUi | default "vue" | quote }}
  186. {{- end }}
  187. {{- if gt (int .Values.auditLog.level) 0 }}
  188. - mountPath: /var/log/auditlog
  189. name: audit-log
  190. {{- end }}
  191. {{- if eq .Values.auditLog.destination "sidecar" }}
  192. {{- if gt (int .Values.auditLog.level) 0 }}
  193. # Make audit logs available for Rancher log collector tools.
  194. {{- if .Values.busyboxImage }}
  195. - image: {{ .Values.busyboxImage}}
  196. {{- else }}
  197. - image: {{ .Values.auditLog.image.repository }}:{{.Values.auditLog.image.tag}}
  198. {{- end }}
  199. {{- if .Values.busyboxImagePullPolicy }}
  200. imagePullPolicy: {{ .Values.busyboxImagePullPolicy }}
  201. {{- else }}
  202. imagePullPolicy: {{ .Values.auditLog.image.pullPolicy }}
  203. {{- end }}
  204. name: {{ template "rancher.name" . }}-audit-log
  205. command: ["tail"]
  206. args: ["-F", "/var/log/auditlog/rancher-api-audit.log"]
  207. volumeMounts:
  208. - mountPath: /var/log/auditlog
  209. name: audit-log
  210. {{- end }}
  211. {{- end }}
  212. volumes:
  213. {{- if .Values.additionalTrustedCAs }}
  214. - name: tls-ca-additional-volume
  215. secret:
  216. defaultMode: 0400
  217. secretName: tls-ca-additional
  218. {{- end }}
  219. {{- if .Values.privateCA }}
  220. - name: tls-ca-volume
  221. secret:
  222. defaultMode: 0400
  223. secretName: tls-ca
  224. {{- end }}
  225. {{- if gt (int .Values.auditLog.level) 0 }}
  226. {{- if eq .Values.auditLog.destination "hostPath" }}
  227. - name: audit-log
  228. hostPath:
  229. path: {{ .Values.auditLog.hostPath }}
  230. type: DirectoryOrCreate
  231. {{- else }}
  232. - name: audit-log
  233. emptyDir: {}
  234. {{- end }}
  235. {{- end }}
  236. {{- if and .Values.customLogos.enabled (or (eq .Values.customLogos.volumeKind "persistentVolumeClaim") (and (eq .Values.customLogos.volumeKind "configMap") (.Values.customLogos.volumeName))) }}
  237. - name: custom-logos
  238. {{- if (eq .Values.customLogos.volumeKind "persistentVolumeClaim") }}
  239. persistentVolumeClaim:
  240. claimName: {{ .Values.customLogos.volumeName | default (printf "%s-custom-logos" (include "rancher.fullname" .)) }}
  241. {{- else if (eq .Values.customLogos.volumeKind "configMap") }}
  242. configMap:
  243. name: {{ .Values.customLogos.volumeName }}
  244. {{- end }}
  245. {{- end }}