webhook-deployment.yaml 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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. {{- with .Values.webhook.podSecurityContext }}
  51. {{- if and (.enabled) (gt (keys . | len) 1) }}
  52. securityContext:
  53. {{- include "external-secrets.renderSecurityContext" (dict "securityContext" . "context" $) | nindent 8 }}
  54. {{- end }}
  55. {{- end }}
  56. containers:
  57. - name: webhook
  58. {{- with .Values.webhook.securityContext }}
  59. {{- if and (.enabled) (gt (keys . | len) 1) }}
  60. securityContext:
  61. {{- include "external-secrets.renderSecurityContext" (dict "securityContext" . "context" $) | nindent 12 }}
  62. {{- end }}
  63. {{- end }}
  64. image: {{ include "external-secrets.image" (dict "chartAppVersion" .Chart.AppVersion "image" .Values.webhook.image "context" .) | trim }}
  65. imagePullPolicy: {{ .Values.webhook.image.pullPolicy }}
  66. args:
  67. - webhook
  68. - --port={{ .Values.webhook.port }}
  69. - --dns-name={{ include "external-secrets.fullname" . }}-webhook.{{ template "external-secrets.namespace" . }}.svc
  70. - --cert-dir={{ .Values.webhook.certDir }}
  71. - --check-interval={{ .Values.webhook.certCheckInterval }}
  72. - --metrics-addr=:{{ .Values.webhook.metrics.listen.port }}
  73. - --healthz-addr={{ .Values.webhook.readinessProbe.address }}:{{ .Values.webhook.readinessProbe.port }}
  74. - --loglevel={{ .Values.webhook.log.level }}
  75. - --zap-time-encoding={{ .Values.webhook.log.timeEncoding }}
  76. {{- if .Values.webhook.lookaheadInterval }}
  77. - --lookahead-interval={{ .Values.webhook.lookaheadInterval }}
  78. {{- end }}
  79. {{- if .Values.enableHTTP2 }}
  80. - --enable-http2=true
  81. {{- end }}
  82. {{- range $key, $value := .Values.webhook.extraArgs }}
  83. {{- if $value }}
  84. - --{{ $key }}={{ $value }}
  85. {{- else }}
  86. - --{{ $key }}
  87. {{- end }}
  88. {{- end }}
  89. ports:
  90. - containerPort: {{ .Values.webhook.metrics.listen.port }}
  91. protocol: TCP
  92. name: metrics
  93. - containerPort: {{ .Values.webhook.port }}
  94. protocol: TCP
  95. name: webhook
  96. readinessProbe:
  97. httpGet:
  98. port: {{ .Values.webhook.readinessProbe.port }}
  99. path: /readyz
  100. initialDelaySeconds: 20
  101. periodSeconds: 5
  102. {{- with .Values.webhook.extraEnv }}
  103. env:
  104. {{- toYaml . | nindent 12 }}
  105. {{- end }}
  106. {{- with .Values.webhook.resources }}
  107. resources:
  108. {{- toYaml . | nindent 12 }}
  109. {{- end }}
  110. volumeMounts:
  111. - name: certs
  112. mountPath: {{ .Values.webhook.certDir }}
  113. readOnly: true
  114. {{- if .Values.webhook.extraVolumeMounts }}
  115. {{- toYaml .Values.webhook.extraVolumeMounts | nindent 12 }}
  116. {{- end }}
  117. {{- with .Values.webhook.extraInitContainers }}
  118. initContainers:
  119. {{- tpl (toYaml . | nindent 8) $ }}
  120. {{- end }}
  121. volumes:
  122. - name: certs
  123. secret:
  124. secretName: {{ include "external-secrets.fullname" . }}-webhook
  125. {{- if .Values.webhook.extraVolumes }}
  126. {{- toYaml .Values.webhook.extraVolumes | nindent 8 }}
  127. {{- end }}
  128. {{- with .Values.webhook.nodeSelector | default .Values.global.nodeSelector }}
  129. nodeSelector:
  130. {{- toYaml . | nindent 8 }}
  131. {{- end }}
  132. {{- with .Values.webhook.affinity | default .Values.global.affinity }}
  133. affinity:
  134. {{- toYaml . | nindent 8 }}
  135. {{- end }}
  136. {{- with .Values.webhook.tolerations | default .Values.global.tolerations }}
  137. tolerations:
  138. {{- toYaml . | nindent 8 }}
  139. {{- end }}
  140. {{- with .Values.webhook.topologySpreadConstraints | default .Values.global.topologySpreadConstraints }}
  141. topologySpreadConstraints:
  142. {{- range $constraint := . }}
  143. - {{ toYaml $constraint | nindent 10 | trim }}
  144. {{- if not $constraint.labelSelector }}
  145. labelSelector:
  146. matchLabels:
  147. {{- include "external-secrets-webhook.selectorLabels" $ | nindent 14 }}
  148. {{- end }}
  149. {{- end }}
  150. {{- end }}
  151. {{- if .Values.webhook.priorityClassName }}
  152. priorityClassName: {{ .Values.webhook.priorityClassName }}
  153. {{- end }}
  154. {{- end }}