blob: 6b097f031babac75820ea1cb71c3b099d9f3f5ec [file] [log] [blame]
Giorgi Lekveishvili4ec4c022024-08-17 15:09:24 +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 }}
Giorgi Lekveishviliea328da2026-07-29 12:15:15 +040019 {{- /* 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 }}
Giorgi Lekveishvili4ec4c022024-08-17 15:09:24 +040023 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 }}
Giorgi Lekveishviliea328da2026-07-29 12:15:15 +040047 {{- 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 }}
Giorgi Lekveishvili4ec4c022024-08-17 15:09:24 +040055 spec:
Giorgi Lekveishviliea328da2026-07-29 12:15:15 +040056 {{- if not .Values.cainjector.serviceAccount.create }}
57 {{- with .Values.global.imagePullSecrets }}
58 imagePullSecrets:
59 {{- toYaml . | nindent 8 }}
60 {{- end }}
61 {{- end }}
Giorgi Lekveishvili4ec4c022024-08-17 15:09:24 +040062 serviceAccountName: {{ template "cainjector.serviceAccountName" . }}
63 {{- if hasKey .Values.cainjector "automountServiceAccountToken" }}
64 automountServiceAccountToken: {{ .Values.cainjector.automountServiceAccountToken }}
65 {{- end }}
Giorgi Lekveishviliea328da2026-07-29 12:15:15 +040066 enableServiceLinks: {{ .Values.cainjector.enableServiceLinks }}
Giorgi Lekveishvili4ec4c022024-08-17 15:09:24 +040067 {{- with .Values.global.priorityClassName }}
68 priorityClassName: {{ . | quote }}
69 {{- end }}
Giorgi Lekveishviliea328da2026-07-29 12:15:15 +040070 {{- if (hasKey .Values.global "hostUsers") }}
71 hostUsers: {{ .Values.global.hostUsers }}
72 {{- end }}
Giorgi Lekveishvili4ec4c022024-08-17 15:09:24 +040073 {{- with .Values.cainjector.securityContext }}
74 securityContext:
75 {{- toYaml . | nindent 8 }}
76 {{- end }}
77 containers:
78 - name: {{ .Chart.Name }}-cainjector
Giorgi Lekveishviliea328da2026-07-29 12:15:15 +040079 image: "{{ template "cert-manager.image" (tuple .Values.cainjector.image .Values.imageRegistry .Values.imageNamespace (printf ":%s" .Chart.AppVersion)) }}"
Giorgi Lekveishvili4ec4c022024-08-17 15:09:24 +040080 imagePullPolicy: {{ .Values.cainjector.image.pullPolicy }}
81 args:
Giorgi Lekveishviliea328da2026-07-29 12:15:15 +040082 {{- /* 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 ""))) }}
Giorgi Lekveishvili4ec4c022024-08-17 15:09:24 +040084 - --v={{ .Values.global.logLevel }}
85 {{- end }}
Giorgi Lekveishviliea328da2026-07-29 12:15:15 +040086 {{- if .Values.cainjector.config }}
87 - --config=/var/cert-manager/config/config.yaml
88 {{- end }}
Giorgi Lekveishvili4ec4c022024-08-17 15:09:24 +040089 {{- 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 }}
Giorgi Lekveishviliea328da2026-07-29 12:15:15 +0400101 {{- with .Values.cainjector.featureGates}}
102 - --feature-gates={{ . }}
103 {{- end}}
Giorgi Lekveishvili4ec4c022024-08-17 15:09:24 +0400104 {{- with .Values.cainjector.extraArgs }}
105 {{- toYaml . | nindent 10 }}
106 {{- end }}
Giorgi Lekveishviliea328da2026-07-29 12:15:15 +0400107 {{- 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 }}
Giorgi Lekveishvili4ec4c022024-08-17 15:09:24 +0400116 env:
117 - name: POD_NAMESPACE
118 valueFrom:
119 fieldRef:
120 fieldPath: metadata.namespace
Giorgi Lekveishviliea328da2026-07-29 12:15:15 +0400121 {{- with .Values.cainjector.extraEnv }}
122 {{- toYaml . | nindent 10 }}
123 {{- end }}
Giorgi Lekveishvili4ec4c022024-08-17 15:09:24 +0400124 {{- 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 }}
Giorgi Lekveishviliea328da2026-07-29 12:15:15 +0400132 {{- if or .Values.cainjector.config .Values.cainjector.volumeMounts }}
Giorgi Lekveishvili4ec4c022024-08-17 15:09:24 +0400133 volumeMounts:
Giorgi Lekveishviliea328da2026-07-29 12:15:15 +0400134 {{- if .Values.cainjector.config }}
135 - name: config
136 mountPath: /var/cert-manager/config
137 {{- end }}
138 {{- with .Values.cainjector.volumeMounts }}
Giorgi Lekveishvili4ec4c022024-08-17 15:09:24 +0400139 {{- toYaml . | nindent 12 }}
Giorgi Lekveishviliea328da2026-07-29 12:15:15 +0400140 {{- end }}
Giorgi Lekveishvili4ec4c022024-08-17 15:09:24 +0400141 {{- end }}
Giorgi Lekveishviliea328da2026-07-29 12:15:15 +0400142 {{- $nodeSelector := .Values.global.nodeSelector | default dict }}
143 {{- $nodeSelector = merge $nodeSelector (.Values.cainjector.nodeSelector | default dict) }}
144 {{- with $nodeSelector }}
Giorgi Lekveishvili4ec4c022024-08-17 15:09:24 +0400145 nodeSelector:
Giorgi Lekveishviliea328da2026-07-29 12:15:15 +0400146 {{- range $key, $value := . }}
147 {{ $key }}: {{ $value | quote }}
148 {{- end }}
Giorgi Lekveishvili4ec4c022024-08-17 15:09:24 +0400149 {{- end }}
150 {{- with .Values.cainjector.affinity }}
151 affinity:
152 {{- toYaml . | nindent 8 }}
153 {{- end }}
Giorgi Lekveishviliea328da2026-07-29 12:15:15 +0400154 {{- if .Values.cainjector.runtimeClassName }}
155 runtimeClassName: {{ .Values.cainjector.runtimeClassName | quote }}
156 {{- else if .Values.global.runtimeClassName }}
157 runtimeClassName: {{ .Values.global.runtimeClassName | quote }}
158 {{- end }}
Giorgi Lekveishvili4ec4c022024-08-17 15:09:24 +0400159 {{- with .Values.cainjector.tolerations }}
160 tolerations:
161 {{- toYaml . | nindent 8 }}
162 {{- end }}
163 {{- with .Values.cainjector.topologySpreadConstraints }}
164 topologySpreadConstraints:
165 {{- toYaml . | nindent 8 }}
166 {{- end }}
Giorgi Lekveishviliea328da2026-07-29 12:15:15 +0400167 {{- if or .Values.cainjector.volumes .Values.cainjector.config }}
Giorgi Lekveishvili4ec4c022024-08-17 15:09:24 +0400168 volumes:
Giorgi Lekveishviliea328da2026-07-29 12:15:15 +0400169 {{- if .Values.cainjector.config }}
170 - name: config
171 configMap:
172 name: {{ include "cainjector.fullname" . }}
173 {{- end }}
174 {{ with .Values.cainjector.volumes }}
Giorgi Lekveishvili4ec4c022024-08-17 15:09:24 +0400175 {{- toYaml . | nindent 8 }}
Giorgi Lekveishviliea328da2026-07-29 12:15:15 +0400176 {{- end }}
Giorgi Lekveishvili4ec4c022024-08-17 15:09:24 +0400177 {{- end }}
178{{- end }}