webhook-deployment.yaml 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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.fullname" . }}-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. {{- range $key, $value := .Values.webhook.extraArgs }}
  88. {{- if $value }}
  89. - --{{ $key }}={{ $value }}
  90. {{- else }}
  91. - --{{ $key }}
  92. {{- end }}
  93. {{- end }}
  94. ports:
  95. - containerPort: {{ .Values.webhook.metrics.listen.port }}
  96. protocol: TCP
  97. name: metrics
  98. - containerPort: {{ .Values.webhook.port }}
  99. protocol: TCP
  100. name: webhook
  101. - containerPort: {{ .Values.webhook.readinessProbe.port }}
  102. protocol: TCP
  103. name: ready
  104. readinessProbe:
  105. httpGet:
  106. port: ready
  107. path: /readyz
  108. initialDelaySeconds: 20
  109. periodSeconds: 5
  110. {{- with .Values.webhook.extraEnv }}
  111. env:
  112. {{- toYaml . | nindent 12 }}
  113. {{- end }}
  114. {{- with .Values.webhook.resources }}
  115. resources:
  116. {{- toYaml . | nindent 12 }}
  117. {{- end }}
  118. volumeMounts:
  119. - name: certs
  120. mountPath: {{ .Values.webhook.certDir }}
  121. readOnly: true
  122. {{- if .Values.webhook.extraVolumeMounts }}
  123. {{- toYaml .Values.webhook.extraVolumeMounts | nindent 12 }}
  124. {{- end }}
  125. {{- with .Values.webhook.extraInitContainers }}
  126. initContainers:
  127. {{- tpl (toYaml . | nindent 8) $ }}
  128. {{- end }}
  129. volumes:
  130. - name: certs
  131. secret:
  132. secretName: {{ include "external-secrets.fullname" . }}-webhook
  133. {{- if .Values.webhook.extraVolumes }}
  134. {{- toYaml .Values.webhook.extraVolumes | nindent 8 }}
  135. {{- end }}
  136. {{- with .Values.webhook.hostAliases | default .Values.global.hostAliases }}
  137. hostAliases:
  138. {{- toYaml . | nindent 8 }}
  139. {{- end }}
  140. {{- with .Values.webhook.nodeSelector | default .Values.global.nodeSelector }}
  141. nodeSelector:
  142. {{- toYaml . | nindent 8 }}
  143. {{- end }}
  144. {{- with .Values.webhook.affinity | default .Values.global.affinity }}
  145. affinity:
  146. {{- toYaml . | nindent 8 }}
  147. {{- end }}
  148. {{- with .Values.webhook.tolerations | default .Values.global.tolerations }}
  149. tolerations:
  150. {{- toYaml . | nindent 8 }}
  151. {{- end }}
  152. {{- with .Values.webhook.topologySpreadConstraints | default .Values.global.topologySpreadConstraints }}
  153. topologySpreadConstraints:
  154. {{- range $constraint := . }}
  155. - {{ toYaml $constraint | nindent 10 | trim }}
  156. {{- if not $constraint.labelSelector }}
  157. labelSelector:
  158. matchLabels:
  159. {{- include "external-secrets-webhook.selectorLabels" $ | nindent 14 }}
  160. {{- end }}
  161. {{- end }}
  162. {{- end }}
  163. {{- if .Values.webhook.priorityClassName }}
  164. priorityClassName: {{ .Values.webhook.priorityClassName }}
  165. {{- end }}
  166. {{- end }}