blob: 89f6afe8dd79fd67d7419b372434a5dd9e09c460 [file] [log] [blame]
Giorgi Lekveishviliea328da2026-07-29 12:15:15 +04001{{- if .Values.cainjector.enabled }}
2apiVersion: apps/v1
3kind: Deployment
4metadata:
5 name: {{ include "cainjector.fullname" . }}
6 namespace: {{ include "cert-manager.namespace" . }}
7 labels:
8 app: {{ include "cainjector.name" . }}
9 app.kubernetes.io/name: {{ include "cainjector.name" . }}
10 app.kubernetes.io/instance: {{ .Release.Name }}
11 app.kubernetes.io/component: "cainjector"
12 {{- include "labels" . | nindent 4 }}
13 {{- with .Values.cainjector.deploymentAnnotations }}
14 annotations:
15 {{- toYaml . | nindent 4 }}
16 {{- end }}
17spec:
18 replicas: {{ .Values.cainjector.replicaCount }}
19 {{- /* The if statement below is equivalent to {{- if $value }} but will also return true for 0. */ -}}
20 {{- if not (has (quote .Values.global.revisionHistoryLimit) (list "" (quote ""))) }}
21 revisionHistoryLimit: {{ .Values.global.revisionHistoryLimit }}
22 {{- end }}
23 selector:
24 matchLabels:
25 app.kubernetes.io/name: {{ include "cainjector.name" . }}
26 app.kubernetes.io/instance: {{ .Release.Name }}
27 app.kubernetes.io/component: "cainjector"
28 {{- with .Values.cainjector.strategy }}
29 strategy:
30 {{- toYaml . | nindent 4 }}
31 {{- end }}
32 template:
33 metadata:
34 labels:
35 app: {{ include "cainjector.name" . }}
36 app.kubernetes.io/name: {{ include "cainjector.name" . }}
37 app.kubernetes.io/instance: {{ .Release.Name }}
38 app.kubernetes.io/component: "cainjector"
39 {{- include "labels" . | nindent 8 }}
40 {{- with .Values.cainjector.podLabels }}
41 {{- toYaml . | nindent 8 }}
42 {{- end }}
43 {{- with .Values.cainjector.podAnnotations }}
44 annotations:
45 {{- toYaml . | nindent 8 }}
46 {{- end }}
47 {{- if and .Values.prometheus.enabled (not (or .Values.prometheus.servicemonitor.enabled .Values.prometheus.podmonitor.enabled)) }}
48 {{- if not .Values.cainjector.podAnnotations }}
49 annotations:
50 {{- end }}
51 prometheus.io/path: "/metrics"
52 prometheus.io/scrape: 'true'
53 prometheus.io/port: '9402'
54 {{- end }}
55 spec:
56 {{- if not .Values.cainjector.serviceAccount.create }}
57 {{- with .Values.global.imagePullSecrets }}
58 imagePullSecrets:
59 {{- toYaml . | nindent 8 }}
60 {{- end }}
61 {{- end }}
62 serviceAccountName: {{ template "cainjector.serviceAccountName" . }}
63 {{- if hasKey .Values.cainjector "automountServiceAccountToken" }}
64 automountServiceAccountToken: {{ .Values.cainjector.automountServiceAccountToken }}
65 {{- end }}
66 enableServiceLinks: {{ .Values.cainjector.enableServiceLinks }}
67 {{- with .Values.global.priorityClassName }}
68 priorityClassName: {{ . | quote }}
69 {{- end }}
70 {{- if (hasKey .Values.global "hostUsers") }}
71 hostUsers: {{ .Values.global.hostUsers }}
72 {{- end }}
73 {{- with .Values.cainjector.securityContext }}
74 securityContext:
75 {{- toYaml . | nindent 8 }}
76 {{- end }}
77 containers:
78 - name: {{ .Chart.Name }}-cainjector
79 image: "{{ template "image" (tuple .Values.cainjector.image .Values.imageRegistry .Values.imageNamespace (printf ":%s" .Chart.AppVersion)) }}"
80 imagePullPolicy: {{ .Values.cainjector.image.pullPolicy }}
81 args:
82 {{- /* The if statement below is equivalent to {{- if $value }} but will also return true for 0. */ -}}
83 {{- if not (has (quote .Values.global.logLevel) (list "" (quote ""))) }}
84 - --v={{ .Values.global.logLevel }}
85 {{- end }}
86 {{- if .Values.cainjector.config }}
87 - --config=/var/cert-manager/config/config.yaml
88 {{- end }}
89 {{- with .Values.global.leaderElection }}
90 - --leader-election-namespace={{ .namespace }}
91 {{- if .leaseDuration }}
92 - --leader-election-lease-duration={{ .leaseDuration }}
93 {{- end }}
94 {{- if .renewDeadline }}
95 - --leader-election-renew-deadline={{ .renewDeadline }}
96 {{- end }}
97 {{- if .retryPeriod }}
98 - --leader-election-retry-period={{ .retryPeriod }}
99 {{- end }}
100 {{- end }}
101 {{- with .Values.cainjector.featureGates}}
102 - --feature-gates={{ . }}
103 {{- end}}
104 {{- with .Values.cainjector.extraArgs }}
105 {{- toYaml . | nindent 10 }}
106 {{- end }}
107 {{- if not .Values.prometheus.enabled }}
108 - --metrics-listen-address=0
109 {{- end }}
110 {{- if .Values.prometheus.enabled }}
111 ports:
112 - containerPort: 9402
113 name: http-metrics
114 protocol: TCP
115 {{- end }}
116 env:
117 - name: POD_NAMESPACE
118 valueFrom:
119 fieldRef:
120 fieldPath: metadata.namespace
121 {{- with .Values.cainjector.extraEnv }}
122 {{- toYaml . | nindent 10 }}
123 {{- end }}
124 {{- with .Values.cainjector.containerSecurityContext }}
125 securityContext:
126 {{- toYaml . | nindent 12 }}
127 {{- end }}
128 {{- with .Values.cainjector.resources }}
129 resources:
130 {{- toYaml . | nindent 12 }}
131 {{- end }}
132 {{- if or .Values.cainjector.config .Values.cainjector.volumeMounts }}
133 volumeMounts:
134 {{- if .Values.cainjector.config }}
135 - name: config
136 mountPath: /var/cert-manager/config
137 {{- end }}
138 {{- with .Values.cainjector.volumeMounts }}
139 {{- toYaml . | nindent 12 }}
140 {{- end }}
141 {{- end }}
142 {{- $nodeSelector := .Values.global.nodeSelector | default dict }}
143 {{- $nodeSelector = merge $nodeSelector (.Values.cainjector.nodeSelector | default dict) }}
144 {{- with $nodeSelector }}
145 nodeSelector:
146 {{- range $key, $value := . }}
147 {{ $key }}: {{ $value | quote }}
148 {{- end }}
149 {{- end }}
150 {{- with .Values.cainjector.affinity }}
151 affinity:
152 {{- toYaml . | nindent 8 }}
153 {{- end }}
154 {{- with .Values.cainjector.tolerations }}
155 tolerations:
156 {{- toYaml . | nindent 8 }}
157 {{- end }}
158 {{- with .Values.cainjector.topologySpreadConstraints }}
159 topologySpreadConstraints:
160 {{- toYaml . | nindent 8 }}
161 {{- end }}
162 {{- if or .Values.cainjector.volumes .Values.cainjector.config }}
163 volumes:
164 {{- if .Values.cainjector.config }}
165 - name: config
166 configMap:
167 name: {{ include "cainjector.fullname" . }}
168 {{- end }}
169 {{ with .Values.cainjector.volumes }}
170 {{- toYaml . | nindent 8 }}
171 {{- end }}
172 {{- end }}
173{{- end }}