webhook-deployment.yaml 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. {{- if .Values.webhook.create }}
  2. apiVersion: apps/v1
  3. kind: Deployment
  4. metadata:
  5. name: {{ include "external-secrets.fullname" . }}-webhook
  6. namespace: {{ template "external-secrets.namespace" . }}
  7. labels:
  8. {{- include "external-secrets-webhook.labels" . | nindent 4 }}
  9. {{- with .Values.webhook.deploymentAnnotations }}
  10. annotations:
  11. {{- toYaml . | nindent 4 }}
  12. {{- end }}
  13. spec:
  14. replicas: {{ .Values.webhook.replicaCount }}
  15. revisionHistoryLimit: {{ .Values.webhook.revisionHistoryLimit }}
  16. selector:
  17. matchLabels:
  18. {{- include "external-secrets-webhook.selectorLabels" . | nindent 6 }}
  19. {{- with .Values.webhook.strategy }}
  20. strategy:
  21. {{- toYaml . | nindent 4 }}
  22. {{- end }}
  23. template:
  24. metadata:
  25. {{- if .Values.webhook.podAnnotations }}
  26. annotations:
  27. {{- toYaml .Values.webhook.podAnnotations | nindent 8 }}
  28. {{- else if .Values.global.podAnnotations }}
  29. annotations:
  30. {{- toYaml .Values.global.podAnnotations | nindent 8 }}
  31. {{- end }}
  32. labels:
  33. {{- include "external-secrets-webhook.labels" . | nindent 8 }}
  34. {{- if .Values.webhook.podLabels }}
  35. {{- toYaml .Values.webhook.podLabels | nindent 8 }}
  36. {{- else if .Values.global.podLabels }}
  37. {{- toYaml .Values.global.podLabels | nindent 8 }}
  38. {{- end }}
  39. spec:
  40. {{- if .Values.webhook.imagePullSecrets }}
  41. imagePullSecrets:
  42. {{- toYaml .Values.webhook.imagePullSecrets | nindent 8 }}
  43. {{- else if .Values.global.imagePullSecrets }}
  44. imagePullSecrets:
  45. {{- toYaml .Values.global.imagePullSecrets | nindent 8 }}
  46. {{- end }}
  47. hostNetwork: {{ .Values.webhook.hostNetwork}}
  48. serviceAccountName: {{ include "external-secrets-webhook.serviceAccountName" . }}
  49. automountServiceAccountToken: {{ .Values.webhook.serviceAccount.automount }}
  50. {{- if (semverCompare ">= 1.33-0" .Capabilities.KubeVersion.Version) }}
  51. {{- if kindIs "bool" .Values.webhook.hostUsers }}
  52. hostUsers: {{ .Values.webhook.hostUsers }}
  53. {{- end }}
  54. {{- end }}
  55. {{- with .Values.webhook.podSecurityContext }}
  56. {{- if and (.enabled) (gt (keys . | len) 1) }}
  57. securityContext:
  58. {{- include "external-secrets.renderSecurityContext" (dict "securityContext" . "context" $) | nindent 8 }}
  59. {{- end }}
  60. {{- end }}
  61. containers:
  62. - name: webhook
  63. {{- with .Values.webhook.securityContext }}
  64. {{- if and (.enabled) (gt (keys . | len) 1) }}
  65. securityContext:
  66. {{- include "external-secrets.renderSecurityContext" (dict "securityContext" . "context" $) | nindent 12 }}
  67. {{- end }}
  68. {{- end }}
  69. image: {{ include "external-secrets.image" (dict "chartAppVersion" .Chart.AppVersion "image" .Values.webhook.image "context" .) | trim }}
  70. imagePullPolicy: {{ .Values.webhook.image.pullPolicy }}
  71. args:
  72. - webhook
  73. - --port={{ .Values.webhook.port }}
  74. - --dns-name={{ include "external-secrets.componentName" (list . "-webhook") }}.{{ template "external-secrets.namespace" . }}.svc
  75. - --cert-dir={{ .Values.webhook.certDir }}
  76. - --check-interval={{ .Values.webhook.certCheckInterval }}
  77. - --metrics-addr=:{{ .Values.webhook.metrics.listen.port }}
  78. - --healthz-addr={{ .Values.webhook.readinessProbe.address }}:{{ .Values.webhook.readinessProbe.port }}
  79. - --loglevel={{ .Values.webhook.log.level }}
  80. - --zap-time-encoding={{ .Values.webhook.log.timeEncoding }}
  81. {{- if .Values.webhook.lookaheadInterval }}
  82. - --lookahead-interval={{ .Values.webhook.lookaheadInterval }}
  83. {{- end }}
  84. {{- if .Values.enableHTTP2 }}
  85. - --enable-http2=true
  86. {{- end }}
  87. {{- if (.Values.webhook.tls.minVersion | default .Values.tls.minVersion) }}
  88. - --tls-min-version={{ .Values.webhook.tls.minVersion | default .Values.tls.minVersion }}
  89. {{- end }}
  90. {{- if (.Values.webhook.tls.ciphers | default .Values.tls.ciphers) }}
  91. - --tls-ciphers={{ .Values.webhook.tls.ciphers | default .Values.tls.ciphers }}
  92. {{- end }}
  93. {{- if (.Values.webhook.tls.curvePreferences | default .Values.tls.curvePreferences) }}
  94. - --tls-curve-preferences={{ join "," (.Values.webhook.tls.curvePreferences | default .Values.tls.curvePreferences) }}
  95. {{- end }}
  96. {{- range $key, $value := .Values.webhook.extraArgs }}
  97. {{- if $value }}
  98. - --{{ $key }}={{ $value }}
  99. {{- else }}
  100. - --{{ $key }}
  101. {{- end }}
  102. {{- end }}
  103. {{- if .Values.webhook.metrics.listen.secure.enabled }}
  104. - --metrics-secure=true
  105. - --metrics-cert-dir={{ .Values.webhook.metrics.listen.secure.certDir }}
  106. - --metrics-cert-name={{ .Values.webhook.metrics.listen.secure.certFile }}
  107. - --metrics-key-name={{ .Values.webhook.metrics.listen.secure.keyFile }}
  108. {{- end }}
  109. {{- if .Values.webhook.metrics.listen.auth.enabled }}
  110. - --metrics-auth=true
  111. {{- end }}
  112. ports:
  113. - containerPort: {{ .Values.webhook.metrics.listen.port }}
  114. protocol: TCP
  115. name: metrics
  116. - containerPort: {{ .Values.webhook.port }}
  117. protocol: TCP
  118. name: webhook
  119. - containerPort: {{ .Values.webhook.readinessProbe.port }}
  120. protocol: TCP
  121. name: ready
  122. {{- if .Values.webhook.livenessProbe.enabled }}
  123. livenessProbe:
  124. httpGet:
  125. port: {{ .Values.webhook.livenessProbe.port }}
  126. path: /healthz
  127. initialDelaySeconds: {{ .Values.webhook.livenessProbe.initialDelaySeconds }}
  128. periodSeconds: {{ .Values.webhook.livenessProbe.periodSeconds }}
  129. timeoutSeconds: {{ .Values.webhook.livenessProbe.timeoutSeconds }}
  130. failureThreshold: {{ .Values.webhook.livenessProbe.failureThreshold }}
  131. successThreshold: {{ .Values.webhook.livenessProbe.successThreshold }}
  132. {{- end }}
  133. {{- if .Values.webhook.readinessProbe.enabled }}
  134. readinessProbe:
  135. httpGet:
  136. port: ready
  137. path: /readyz
  138. initialDelaySeconds: {{ .Values.webhook.readinessProbe.initialDelaySeconds }}
  139. periodSeconds: {{ .Values.webhook.readinessProbe.periodSeconds }}
  140. timeoutSeconds: {{ .Values.webhook.readinessProbe.timeoutSeconds }}
  141. failureThreshold: {{ .Values.webhook.readinessProbe.failureThreshold }}
  142. successThreshold: {{ .Values.webhook.readinessProbe.successThreshold }}
  143. {{- end }}
  144. {{- if .Values.webhook.startupProbe.enabled }}
  145. startupProbe:
  146. httpGet:
  147. port: ready
  148. path: /readyz
  149. initialDelaySeconds: {{ .Values.webhook.startupProbe.initialDelaySeconds }}
  150. periodSeconds: {{ .Values.webhook.startupProbe.periodSeconds }}
  151. failureThreshold: {{ .Values.webhook.startupProbe.failureThreshold }}
  152. {{- end }}
  153. {{- with .Values.webhook.extraEnv }}
  154. env:
  155. {{- toYaml . | nindent 12 }}
  156. {{- end }}
  157. {{- with .Values.webhook.resources }}
  158. resources:
  159. {{- toYaml . | nindent 12 }}
  160. {{- end }}
  161. volumeMounts:
  162. - name: certs
  163. mountPath: {{ .Values.webhook.certDir }}
  164. readOnly: true
  165. {{- if .Values.webhook.extraVolumeMounts }}
  166. {{- toYaml .Values.webhook.extraVolumeMounts | nindent 12 }}
  167. {{- end }}
  168. {{- with .Values.webhook.extraInitContainers }}
  169. initContainers:
  170. {{- tpl (toYaml . | nindent 8) $ }}
  171. {{- end }}
  172. volumes:
  173. - name: certs
  174. secret:
  175. secretName: {{ include "external-secrets.fullname" . }}-webhook
  176. {{- if .Values.webhook.extraVolumes }}
  177. {{- toYaml .Values.webhook.extraVolumes | nindent 8 }}
  178. {{- end }}
  179. {{- with .Values.webhook.hostAliases | default .Values.global.hostAliases }}
  180. hostAliases:
  181. {{- toYaml . | nindent 8 }}
  182. {{- end }}
  183. {{- with .Values.webhook.nodeSelector | default .Values.global.nodeSelector }}
  184. nodeSelector:
  185. {{- toYaml . | nindent 8 }}
  186. {{- end }}
  187. {{- with .Values.webhook.affinity | default .Values.global.affinity }}
  188. affinity:
  189. {{- toYaml . | nindent 8 }}
  190. {{- end }}
  191. {{- with .Values.webhook.tolerations | default .Values.global.tolerations }}
  192. tolerations:
  193. {{- toYaml . | nindent 8 }}
  194. {{- end }}
  195. {{- with .Values.webhook.topologySpreadConstraints | default .Values.global.topologySpreadConstraints }}
  196. topologySpreadConstraints:
  197. {{- range $constraint := . }}
  198. - {{ toYaml $constraint | nindent 10 | trim }}
  199. {{- if not $constraint.labelSelector }}
  200. labelSelector:
  201. matchLabels:
  202. {{- include "external-secrets-webhook.selectorLabels" $ | nindent 14 }}
  203. {{- end }}
  204. {{- end }}
  205. {{- end }}
  206. {{- if .Values.webhook.priorityClassName }}
  207. priorityClassName: {{ .Values.webhook.priorityClassName }}
  208. {{- end }}
  209. {{- if .Values.webhook.schedulerName }}
  210. schedulerName: {{ .Values.webhook.schedulerName | quote }}
  211. {{- end }}
  212. {{- if .Values.webhook.runtimeClassName }}
  213. runtimeClassName: {{ .Values.webhook.runtimeClassName | quote }}
  214. {{- end }}
  215. {{- end }}