Skip to content
This repository was archived by the owner on Apr 25, 2023. It is now read-only.

Commit 2d92596

Browse files
committed
enable cert-manager
Signed-off-by: alejandroEsc <[email protected]>
1 parent c4616b6 commit 2d92596

File tree

4 files changed

+78
-6
lines changed

4 files changed

+78
-6
lines changed

charts/kubefed/Chart.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ dependencies:
66
- name: controllermanager
77
version: 0.0.3
88
repository: "https://localhost/" # Required but unused.
9-
condition: controllermanager.enabled
9+
condition: controllermanager.enabled

charts/kubefed/charts/controllermanager/templates/deployments.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ metadata:
55
namespace: {{ .Release.Namespace }}
66
labels:
77
kubefed-control-plane: controller-manager
8+
{{- if .Values.controller.annotations }}
9+
annotations:
10+
{{ toYaml .Values.controller.annotations | indent 4 }}
11+
{{- end }}
812
spec:
913
replicas: {{ .Values.controller.replicaCount }}
1014
selector:
@@ -60,6 +64,10 @@ metadata:
6064
name: kubefed-admission-webhook
6165
labels:
6266
kubefed-admission-webhook: "true"
67+
{{- if .Values.webhook.annotations }}
68+
annotations:
69+
{{ toYaml .Values.webhook.annotations | indent 4 }}
70+
{{- end }}
6371
spec:
6472
replicas: 1
6573
selector:

charts/kubefed/charts/controllermanager/templates/webhook.yaml

+64-5
Original file line numberDiff line numberDiff line change
@@ -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 }}
1620
webhooks:
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
101111
metadata:
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 }}
107117
webhooks:
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
---
131144
apiVersion: v1
132145
kind: Secret
@@ -137,3 +150,49 @@ type: kubernetes.io/tls
137150
stringData:
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 }}

charts/kubefed/values.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ controllermanager:
2727
FederatedIngress:
2828

2929
controller:
30+
annotations: {}
3031
replicaCount: 2
3132
repository: quay.io/kubernetes-multicluster
3233
image: kubefed
@@ -43,6 +44,7 @@ controllermanager:
4344
cpu: 100m
4445
memory: 64Mi
4546
webhook:
47+
annotations: {}
4648
repository: quay.io/kubernetes-multicluster
4749
image: kubefed
4850
tag: canary
@@ -58,6 +60,9 @@ controllermanager:
5860
cpu: 100m
5961
memory: 64Mi
6062

63+
certManager:
64+
enabled: false
65+
6166

6267
## Configuration global values for all charts
6368
##

0 commit comments

Comments
 (0)