blob: d2b10ae86b67febd7399947927ced504913dd614 [file] [log] [blame]
Giorgi Lekveishvilid1234c12023-06-19 10:37:06 +04001apiVersion: apps/v1
2kind: Deployment
3metadata:
4 name: {{ include "webhook.fullname" . }}
5 namespace: {{ include "cert-manager.namespace" . }}
6 labels:
7 app: {{ include "webhook.name" . }}
8 app.kubernetes.io/name: {{ include "webhook.name" . }}
9 app.kubernetes.io/instance: {{ .Release.Name }}
10 app.kubernetes.io/component: "webhook"
11 {{- include "labels" . | nindent 4 }}
12 {{- with .Values.webhook.deploymentAnnotations }}
13 annotations:
14 {{- toYaml . | nindent 4 }}
15 {{- end }}
16spec:
17 replicas: {{ .Values.webhook.replicaCount }}
gio33d62932026-07-23 16:39:35 +040018 {{- /* The if statement below is equivalent to {{- if $value }} but will also return true for 0. */ -}}
19 {{- if not (has (quote .Values.global.revisionHistoryLimit) (list "" (quote ""))) }}
20 revisionHistoryLimit: {{ .Values.global.revisionHistoryLimit }}
21 {{- end }}
Giorgi Lekveishvilid1234c12023-06-19 10:37:06 +040022 selector:
23 matchLabels:
24 app.kubernetes.io/name: {{ include "webhook.name" . }}
25 app.kubernetes.io/instance: {{ .Release.Name }}
26 app.kubernetes.io/component: "webhook"
27 {{- with .Values.webhook.strategy }}
28 strategy:
29 {{- toYaml . | nindent 4 }}
30 {{- end }}
31 template:
32 metadata:
33 labels:
34 app: {{ include "webhook.name" . }}
35 app.kubernetes.io/name: {{ include "webhook.name" . }}
36 app.kubernetes.io/instance: {{ .Release.Name }}
37 app.kubernetes.io/component: "webhook"
38 {{- include "labels" . | nindent 8 }}
39 {{- with .Values.webhook.podLabels }}
40 {{- toYaml . | nindent 8 }}
41 {{- end }}
42 {{- with .Values.webhook.podAnnotations }}
43 annotations:
44 {{- toYaml . | nindent 8 }}
45 {{- end }}
gio33d62932026-07-23 16:39:35 +040046 {{- if and .Values.prometheus.enabled (not (or .Values.prometheus.servicemonitor.enabled .Values.prometheus.podmonitor.enabled)) }}
47 {{- if not .Values.webhook.podAnnotations }}
48 annotations:
49 {{- end }}
50 prometheus.io/path: "/metrics"
51 prometheus.io/scrape: 'true'
52 prometheus.io/port: '9402'
53 {{- end }}
Giorgi Lekveishvilid1234c12023-06-19 10:37:06 +040054 spec:
gio33d62932026-07-23 16:39:35 +040055 {{- if not .Values.webhook.serviceAccount.create }}
56 {{- with .Values.global.imagePullSecrets }}
57 imagePullSecrets:
58 {{- toYaml . | nindent 8 }}
59 {{- end }}
60 {{- end }}
Giorgi Lekveishvilid1234c12023-06-19 10:37:06 +040061 serviceAccountName: {{ template "webhook.serviceAccountName" . }}
62 {{- if hasKey .Values.webhook "automountServiceAccountToken" }}
63 automountServiceAccountToken: {{ .Values.webhook.automountServiceAccountToken }}
64 {{- end }}
gio33d62932026-07-23 16:39:35 +040065 enableServiceLinks: {{ .Values.webhook.enableServiceLinks }}
Giorgi Lekveishvilid1234c12023-06-19 10:37:06 +040066 {{- with .Values.global.priorityClassName }}
67 priorityClassName: {{ . | quote }}
68 {{- end }}
giod55d03a2026-07-23 16:57:48 +040069 {{- if (hasKey .Values.global "hostUsers") }}
70 hostUsers: {{ .Values.global.hostUsers }}
71 {{- end }}
Giorgi Lekveishvilid1234c12023-06-19 10:37:06 +040072 {{- with .Values.webhook.securityContext }}
73 securityContext:
74 {{- toYaml . | nindent 8 }}
75 {{- end }}
76 {{- if .Values.webhook.hostNetwork }}
77 hostNetwork: true
78 {{- end }}
gio33d62932026-07-23 16:39:35 +040079 {{- if .Values.webhook.hostNetwork }}
80 dnsPolicy: ClusterFirstWithHostNet
81 {{- end }}
Giorgi Lekveishvilid1234c12023-06-19 10:37:06 +040082 containers:
83 - name: {{ .Chart.Name }}-webhook
gio33d62932026-07-23 16:39:35 +040084 image: "{{ template "image" (tuple .Values.webhook.image $.Chart.AppVersion) }}"
Giorgi Lekveishvilid1234c12023-06-19 10:37:06 +040085 imagePullPolicy: {{ .Values.webhook.image.pullPolicy }}
86 args:
gio33d62932026-07-23 16:39:35 +040087 {{- /* The if statement below is equivalent to {{- if $value }} but will also return true for 0. */ -}}
88 {{- if not (has (quote .Values.global.logLevel) (list "" (quote ""))) }}
Giorgi Lekveishvilid1234c12023-06-19 10:37:06 +040089 - --v={{ .Values.global.logLevel }}
90 {{- end }}
91 {{- if .Values.webhook.config }}
92 - --config=/var/cert-manager/config/config.yaml
93 {{- end }}
94 {{- $config := default .Values.webhook.config "" }}
95 {{ if not $config.securePort -}}
96 - --secure-port={{ .Values.webhook.securePort }}
97 {{- end }}
gio33d62932026-07-23 16:39:35 +040098 {{- if .Values.webhook.featureGates }}
99 - --feature-gates={{ .Values.webhook.featureGates }}
Giorgi Lekveishvilid1234c12023-06-19 10:37:06 +0400100 {{- end }}
101 {{- $tlsConfig := default $config.tlsConfig "" }}
102 {{ if or (not $config.tlsConfig) (and (not $tlsConfig.dynamic) (not $tlsConfig.filesystem) ) -}}
103 - --dynamic-serving-ca-secret-namespace=$(POD_NAMESPACE)
104 - --dynamic-serving-ca-secret-name={{ template "webhook.fullname" . }}-ca
105 - --dynamic-serving-dns-names={{ template "webhook.fullname" . }}
106 - --dynamic-serving-dns-names={{ template "webhook.fullname" . }}.$(POD_NAMESPACE)
107 - --dynamic-serving-dns-names={{ template "webhook.fullname" . }}.$(POD_NAMESPACE).svc
giod55d03a2026-07-23 16:57:48 +0400108 {{- if .Values.webhook.url.host }}
Giorgi Lekveishvilid1234c12023-06-19 10:37:06 +0400109 - --dynamic-serving-dns-names={{ .Values.webhook.url.host }}
110 {{- end }}
111 {{- end }}
112 {{- with .Values.webhook.extraArgs }}
113 {{- toYaml . | nindent 10 }}
114 {{- end }}
gio33d62932026-07-23 16:39:35 +0400115 {{- if not .Values.prometheus.enabled }}
116 - --metrics-listen-address=0
117 {{- end }}
Giorgi Lekveishvilid1234c12023-06-19 10:37:06 +0400118 ports:
119 - name: https
120 protocol: TCP
121 {{- if $config.securePort }}
122 containerPort: {{ $config.securePort }}
123 {{- else if .Values.webhook.securePort }}
124 containerPort: {{ .Values.webhook.securePort }}
125 {{- else }}
126 containerPort: 6443
127 {{- end }}
128 - name: healthcheck
129 protocol: TCP
130 {{- if $config.healthzPort }}
131 containerPort: {{ $config.healthzPort }}
132 {{- else }}
133 containerPort: 6080
134 {{- end }}
gio33d62932026-07-23 16:39:35 +0400135 {{- if .Values.prometheus.enabled }}
136 - containerPort: 9402
137 name: http-metrics
138 protocol: TCP
139 {{- end }}
Giorgi Lekveishvilid1234c12023-06-19 10:37:06 +0400140 livenessProbe:
141 httpGet:
142 path: /livez
giob6e9f2f2026-07-23 16:53:10 +0400143 port: healthcheck
Giorgi Lekveishvilid1234c12023-06-19 10:37:06 +0400144 scheme: HTTP
145 initialDelaySeconds: {{ .Values.webhook.livenessProbe.initialDelaySeconds }}
146 periodSeconds: {{ .Values.webhook.livenessProbe.periodSeconds }}
147 timeoutSeconds: {{ .Values.webhook.livenessProbe.timeoutSeconds }}
148 successThreshold: {{ .Values.webhook.livenessProbe.successThreshold }}
149 failureThreshold: {{ .Values.webhook.livenessProbe.failureThreshold }}
150 readinessProbe:
151 httpGet:
152 path: /healthz
giob6e9f2f2026-07-23 16:53:10 +0400153 port: healthcheck
Giorgi Lekveishvilid1234c12023-06-19 10:37:06 +0400154 scheme: HTTP
155 initialDelaySeconds: {{ .Values.webhook.readinessProbe.initialDelaySeconds }}
156 periodSeconds: {{ .Values.webhook.readinessProbe.periodSeconds }}
157 timeoutSeconds: {{ .Values.webhook.readinessProbe.timeoutSeconds }}
158 successThreshold: {{ .Values.webhook.readinessProbe.successThreshold }}
159 failureThreshold: {{ .Values.webhook.readinessProbe.failureThreshold }}
160 {{- with .Values.webhook.containerSecurityContext }}
161 securityContext:
162 {{- toYaml . | nindent 12 }}
163 {{- end }}
164 env:
165 - name: POD_NAMESPACE
166 valueFrom:
167 fieldRef:
168 fieldPath: metadata.namespace
gio33d62932026-07-23 16:39:35 +0400169 {{- with .Values.webhook.extraEnv }}
170 {{- toYaml . | nindent 10 }}
171 {{- end }}
Giorgi Lekveishvilid1234c12023-06-19 10:37:06 +0400172 {{- with .Values.webhook.resources }}
173 resources:
174 {{- toYaml . | nindent 12 }}
175 {{- end }}
Giorgi Lekveishvili0048a782023-06-20 18:32:21 +0400176 {{- if or .Values.webhook.config .Values.webhook.volumeMounts }}
Giorgi Lekveishvilid1234c12023-06-19 10:37:06 +0400177 volumeMounts:
Giorgi Lekveishvili0048a782023-06-20 18:32:21 +0400178 {{- if .Values.webhook.config }}
Giorgi Lekveishvilid1234c12023-06-19 10:37:06 +0400179 - name: config
180 mountPath: /var/cert-manager/config
Giorgi Lekveishvili0048a782023-06-20 18:32:21 +0400181 {{- end }}
gio33d62932026-07-23 16:39:35 +0400182 {{- with .Values.webhook.volumeMounts }}
183 {{- toYaml . | nindent 12 }}
Giorgi Lekveishvili0048a782023-06-20 18:32:21 +0400184 {{- end }}
Giorgi Lekveishvilid1234c12023-06-19 10:37:06 +0400185 {{- end }}
giod55d03a2026-07-23 16:57:48 +0400186 {{- $nodeSelector := .Values.global.nodeSelector | default dict }}
187 {{- $nodeSelector = merge $nodeSelector (.Values.webhook.nodeSelector | default dict) }}
188 {{- with $nodeSelector }}
Giorgi Lekveishvilid1234c12023-06-19 10:37:06 +0400189 nodeSelector:
giob6e9f2f2026-07-23 16:53:10 +0400190 {{- range $key, $value := . }}
191 {{ $key }}: {{ $value | quote }}
192 {{- end }}
Giorgi Lekveishvilid1234c12023-06-19 10:37:06 +0400193 {{- end }}
194 {{- with .Values.webhook.affinity }}
195 affinity:
196 {{- toYaml . | nindent 8 }}
197 {{- end }}
198 {{- with .Values.webhook.tolerations }}
199 tolerations:
200 {{- toYaml . | nindent 8 }}
201 {{- end }}
202 {{- with .Values.webhook.topologySpreadConstraints }}
203 topologySpreadConstraints:
204 {{- toYaml . | nindent 8 }}
205 {{- end }}
Giorgi Lekveishvili0048a782023-06-20 18:32:21 +0400206 {{- if or .Values.webhook.config .Values.webhook.volumes }}
Giorgi Lekveishvilid1234c12023-06-19 10:37:06 +0400207 volumes:
Giorgi Lekveishvili0048a782023-06-20 18:32:21 +0400208 {{- if .Values.webhook.config }}
Giorgi Lekveishvilid1234c12023-06-19 10:37:06 +0400209 - name: config
210 configMap:
211 name: {{ include "webhook.fullname" . }}
Giorgi Lekveishvili0048a782023-06-20 18:32:21 +0400212 {{- end }}
gio33d62932026-07-23 16:39:35 +0400213 {{- with .Values.webhook.volumes }}
214 {{- toYaml . | nindent 8 }}
Giorgi Lekveishvili0048a782023-06-20 18:32:21 +0400215 {{- end }}
Giorgi Lekveishvilid1234c12023-06-19 10:37:06 +0400216 {{- end }}