@@ -10,17 +10,23 @@ metadata:
1010# using the namespace.
1111{{- if and .Values.global.scope (eq .Values.global.scope "Namespaced") }}
1212 name : validations.core.kubefed.io-{{ .Release.Namespace }}
13- {{ else }}
13+ {{- else }}
1414 name : validations.core.kubefed.io
15- {{ end }}
15+ {{- end }}
16+ annotations :
17+ {{- if .Values.certManager.enabled }}
18+ certmanager.k8s.io/inject-ca-from : {{ printf "%s/%s%s" .Release.Namespace .Release.Name "-root-certificate" | quote }}
19+ {{- end }}
1620webhooks :
1721- name : federatedtypeconfigs.core.kubefed.io
1822 clientConfig :
1923 service :
2024 namespace : {{ .Release.Namespace | quote }}
2125 name : kubefed-admission-webhook
2226 path : /validate-federatedtypeconfigs
27+ {{- if not .Values.certManager.enabled }}
2328 caBundle : {{ b64enc $ca.Cert | quote }}
29+ {{- end }}
2430 rules :
2531 - operations :
2632 - CREATE
@@ -50,7 +56,9 @@ webhooks:
5056 namespace : {{ .Release.Namespace | quote }}
5157 name : kubefed-admission-webhook
5258 path : /validate-kubefedcluster
59+ {{- if not .Values.certManager.enabled }}
5360 caBundle : {{ b64enc $ca.Cert | quote }}
61+ {{- end }}
5462 rules :
5563 - operations :
5664 - CREATE
@@ -75,7 +83,9 @@ webhooks:
7583 namespace : {{ .Release.Namespace | quote }}
7684 name : kubefed-admission-webhook
7785 path : /validate-kubefedconfig
86+ {{- if not .Values.certManager.enabled }}
7887 caBundle : {{ b64enc $ca.Cert | quote }}
88+ {{- end }}
7989 rules :
8090 - operations :
8191 - CREATE
@@ -92,7 +102,7 @@ webhooks:
92102 namespaceSelector :
93103 matchLabels :
94104 name : {{ .Release.Namespace }}
95- {{ end }}
105+ {{- end }}
96106---
97107# The same comments for ValidatingWebhookConfiguration apply here to
98108# MutatingWebhookConfiguration.
@@ -101,17 +111,19 @@ kind: MutatingWebhookConfiguration
101111metadata :
102112{{- if and .Values.global.scope (eq .Values.global.scope "Namespaced") }}
103113 name : mutation.core.kubefed.io-{{ .Release.Namespace }}
104- {{ else }}
114+ {{- else }}
105115 name : mutation.core.kubefed.io
106- {{ end }}
116+ {{- end }}
107117webhooks :
108118- name : kubefedconfigs.core.kubefed.io
109119 clientConfig :
110120 service :
111121 namespace : {{ .Release.Namespace | quote }}
112122 name : kubefed-admission-webhook
113123 path : /default-kubefedconfig
124+ {{- if not .Values.certManager.enabled }}
114125 caBundle : {{ b64enc $ca.Cert | quote }}
126+ {{- end }}
115127 rules :
116128 - operations :
117129 - CREATE
@@ -127,6 +139,7 @@ webhooks:
127139 matchLabels :
128140 name : {{ .Release.Namespace }}
129141{{ end }}
142+ {{- if not .Values.certManager.enabled }}
130143---
131144apiVersion : v1
132145kind : Secret
@@ -137,3 +150,49 @@ type: kubernetes.io/tls
137150stringData :
138151 tls.crt : {{ $cert.Cert | quote }}
139152 tls.key : {{ $cert.Key | quote }}
153+ {{- else }}
154+ ---
155+ apiVersion : certmanager.k8s.io/v1alpha1
156+ kind : Issuer
157+ metadata :
158+ name : {{ .Release.Name }}-ca-issuer
159+ spec :
160+ selfSigned : {}
161+ ---
162+ # Generate a CA Certificate used to sign certificates for the webhook
163+ apiVersion : certmanager.k8s.io/v1alpha1
164+ kind : Certificate
165+ metadata :
166+ name : {{ .Release.Name}}-root-certificate
167+ spec :
168+ secretName : {{ .Release.Name }}-root-ca
169+ duration : 8760h # 1y
170+ issuerRef :
171+ name : {{ .Release.Name }}-ca-issuer
172+ commonName : " ca.webhook.kubefed"
173+ isCA : true
174+ ---
175+ # Create an Issuer that uses the above generated CA certificate to issue certs
176+ apiVersion : certmanager.k8s.io/v1alpha1
177+ kind : Issuer
178+ metadata :
179+ name : {{ .Release.Name }}-issuer
180+ spec :
181+ ca :
182+ secretName : {{ .Release.Name}}-root-ca
183+ ---
184+ # Finally, generate a serving certificate for the webhook to use
185+ apiVersion : certmanager.k8s.io/v1alpha1
186+ kind : Certificate
187+ metadata :
188+ name : {{ .Release.Name }}-certificate
189+ spec :
190+ secretName : kubefed-admission-webhook-serving-cert
191+ duration : 8760h # 1y
192+ issuerRef :
193+ name : {{ .Release.Name }}-issuer
194+ dnsNames :
195+ - kubefed-admission-webhook
196+ - {{ $altName1 }}
197+ - {{ $altName2 }}
198+ {{- end }}
0 commit comments