@@ -10,17 +10,23 @@ metadata:
10
10
# using the namespace.
11
11
{{- if and .Values.global.scope (eq .Values.global.scope "Namespaced") }}
12
12
name : validations.core.kubefed.io-{{ .Release.Namespace }}
13
- {{ else }}
13
+ {{- else }}
14
14
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 }}
16
20
webhooks :
17
21
- name : federatedtypeconfigs.core.kubefed.io
18
22
clientConfig :
19
23
service :
20
24
namespace : {{ .Release.Namespace | quote }}
21
25
name : kubefed-admission-webhook
22
26
path : /validate-federatedtypeconfigs
27
+ {{- if not .Values.certManager.enabled }}
23
28
caBundle : {{ b64enc $ca.Cert | quote }}
29
+ {{- end }}
24
30
rules :
25
31
- operations :
26
32
- CREATE
@@ -50,7 +56,9 @@ webhooks:
50
56
namespace : {{ .Release.Namespace | quote }}
51
57
name : kubefed-admission-webhook
52
58
path : /validate-kubefedcluster
59
+ {{- if not .Values.certManager.enabled }}
53
60
caBundle : {{ b64enc $ca.Cert | quote }}
61
+ {{- end }}
54
62
rules :
55
63
- operations :
56
64
- CREATE
@@ -75,7 +83,9 @@ webhooks:
75
83
namespace : {{ .Release.Namespace | quote }}
76
84
name : kubefed-admission-webhook
77
85
path : /validate-kubefedconfig
86
+ {{- if not .Values.certManager.enabled }}
78
87
caBundle : {{ b64enc $ca.Cert | quote }}
88
+ {{- end }}
79
89
rules :
80
90
- operations :
81
91
- CREATE
@@ -92,7 +102,7 @@ webhooks:
92
102
namespaceSelector :
93
103
matchLabels :
94
104
name : {{ .Release.Namespace }}
95
- {{ end }}
105
+ {{- end }}
96
106
---
97
107
# The same comments for ValidatingWebhookConfiguration apply here to
98
108
# MutatingWebhookConfiguration.
@@ -101,17 +111,19 @@ kind: MutatingWebhookConfiguration
101
111
metadata :
102
112
{{- if and .Values.global.scope (eq .Values.global.scope "Namespaced") }}
103
113
name : mutation.core.kubefed.io-{{ .Release.Namespace }}
104
- {{ else }}
114
+ {{- else }}
105
115
name : mutation.core.kubefed.io
106
- {{ end }}
116
+ {{- end }}
107
117
webhooks :
108
118
- name : kubefedconfigs.core.kubefed.io
109
119
clientConfig :
110
120
service :
111
121
namespace : {{ .Release.Namespace | quote }}
112
122
name : kubefed-admission-webhook
113
123
path : /default-kubefedconfig
124
+ {{- if not .Values.certManager.enabled }}
114
125
caBundle : {{ b64enc $ca.Cert | quote }}
126
+ {{- end }}
115
127
rules :
116
128
- operations :
117
129
- CREATE
@@ -127,6 +139,7 @@ webhooks:
127
139
matchLabels :
128
140
name : {{ .Release.Namespace }}
129
141
{{ end }}
142
+ {{- if not .Values.certManager.enabled }}
130
143
---
131
144
apiVersion : v1
132
145
kind : Secret
@@ -137,3 +150,49 @@ type: kubernetes.io/tls
137
150
stringData :
138
151
tls.crt : {{ $cert.Cert | quote }}
139
152
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