Skip to content

Commit e502aec

Browse files
committed
Kustomize: Update deprecated syntax
This commit updates the following: - patchesStrategicMerge -> patches - patchesJson6902 -> patches - vars and varReference -> replacements - bases -> resources Most of this is straight forward, but the vars -> replacements change is a bit complicated. I have taken inspiration from kubebuilder for how to do the change. In particular I changed the name of the secret that holds the certificate to be static. Previously it was set partially from a variable. I believe it would be unnecessarily complicated to keep this behavior and that a static name does not take away much.
1 parent e2f1a48 commit e502aec

File tree

78 files changed

+693
-474
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+693
-474
lines changed

bootstrap/kubeadm/config/certmanager/certificate.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ metadata:
1515
name: serving-cert # this name should match the one appeared in kustomizeconfig.yaml
1616
namespace: system
1717
spec:
18-
# $(SERVICE_NAME) and $(SERVICE_NAMESPACE) will be substituted by kustomize
18+
# SERVICE_NAME and SERVICE_NAMESPACE will be substituted by kustomize
1919
dnsNames:
20-
- $(SERVICE_NAME).$(SERVICE_NAMESPACE).svc
21-
- $(SERVICE_NAME).$(SERVICE_NAMESPACE).svc.cluster.local
20+
- SERVICE_NAME.SERVICE_NAMESPACE.svc
21+
- SERVICE_NAME.SERVICE_NAMESPACE.svc.cluster.local
2222
issuerRef:
2323
kind: Issuer
2424
name: selfsigned-issuer
25-
secretName: $(SERVICE_NAME)-cert # this secret will not be prefixed, since it's not managed by kustomize
25+
secretName: webhook-service-cert # this secret will not be prefixed, since it's not managed by kustomize
2626
subject:
2727
organizations:
28-
- k8s-sig-cluster-lifecycle
28+
- k8s-sig-cluster-lifecycle

bootstrap/kubeadm/config/certmanager/kustomizeconfig.yaml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,3 @@ nameReference:
66
- kind: Certificate
77
group: cert-manager.io
88
path: spec/issuerRef/name
9-
10-
varReference:
11-
- kind: Certificate
12-
group: cert-manager.io
13-
path: spec/commonName
14-
- kind: Certificate
15-
group: cert-manager.io
16-
path: spec/dnsNames
17-
- kind: Certificate
18-
group: cert-manager.io
19-
path: spec/secretName

bootstrap/kubeadm/config/crd/kustomization.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ resources:
1111
- bases/bootstrap.cluster.x-k8s.io_kubeadmconfigtemplates.yaml
1212
# +kubebuilder:scaffold:crdkustomizeresource
1313

14-
patchesStrategicMerge:
14+
patches:
1515
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix.
1616
# patches here are for enabling the conversion webhook for each CRD
17-
- patches/webhook_in_kubeadmconfigs.yaml
18-
- patches/webhook_in_kubeadmconfigtemplates.yaml
17+
- path: patches/webhook_in_kubeadmconfigs.yaml
18+
- path: patches/webhook_in_kubeadmconfigtemplates.yaml
1919
# +kubebuilder:scaffold:crdkustomizewebhookpatch
2020

2121
# [CERTMANAGER] To enable webhook, uncomment all the sections with [CERTMANAGER] prefix.
2222
# patches here are for enabling the CA injection for each CRD
23-
- patches/cainjection_in_kubeadmconfigs.yaml
24-
- patches/cainjection_in_kubeadmconfigtemplates.yaml
23+
- path: patches/cainjection_in_kubeadmconfigs.yaml
24+
- path: patches/cainjection_in_kubeadmconfigtemplates.yaml
2525
# +kubebuilder:scaffold:crdkustomizecainjectionpatch
2626

2727
# the following config is for teaching kustomize how to do kustomization for CRDs.

bootstrap/kubeadm/config/crd/kustomizeconfig.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,3 @@ namespace:
1212
group: apiextensions.k8s.io
1313
path: spec/conversion/webhook/clientConfig/service/namespace
1414
create: false
15-
16-
varReference:
17-
- path: metadata/annotations

bootstrap/kubeadm/config/crd/patches/cainjection_in_kubeadmconfigs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ apiVersion: apiextensions.k8s.io/v1
44
kind: CustomResourceDefinition
55
metadata:
66
annotations:
7-
cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
7+
cert-manager.io/inject-ca-from: CERTIFICATE_NAMESPACE/CERTIFICATE_NAME
88
name: kubeadmconfigs.bootstrap.cluster.x-k8s.io

bootstrap/kubeadm/config/crd/patches/cainjection_in_kubeadmconfigtemplates.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ apiVersion: apiextensions.k8s.io/v1
44
kind: CustomResourceDefinition
55
metadata:
66
annotations:
7-
cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
7+
cert-manager.io/inject-ca-from: CERTIFICATE_NAMESPACE/CERTIFICATE_NAME
88
name: kubeadmconfigtemplates.bootstrap.cluster.x-k8s.io

bootstrap/kubeadm/config/default/kustomization.yaml

Lines changed: 103 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -7,51 +7,116 @@ commonLabels:
77
cluster.x-k8s.io/provider: "bootstrap-kubeadm"
88

99
resources:
10-
- namespace.yaml
11-
12-
bases:
1310
- ../crd
1411
- ../rbac
1512
- ../manager
1613
- ../webhook
1714
- ../certmanager
15+
- namespace.yaml
1816

19-
patchesStrategicMerge:
17+
patches:
2018
# Provide customizable hook for make targets.
21-
- manager_image_patch.yaml
22-
- manager_pull_policy.yaml
19+
- path: manager_image_patch.yaml
20+
- path: manager_pull_policy.yaml
2321
# Enable webhook.
24-
- manager_webhook_patch.yaml
22+
- path: manager_webhook_patch.yaml
2523
# Inject certificate in the webhook definition.
26-
- webhookcainjection_patch.yaml
27-
28-
vars:
29-
- name: CERTIFICATE_NAMESPACE # namespace of the certificate CR
30-
objref:
31-
kind: Certificate
32-
group: cert-manager.io
33-
version: v1
34-
name: serving-cert # this name should match the one in certificate.yaml
35-
fieldref:
36-
fieldpath: metadata.namespace
37-
- name: CERTIFICATE_NAME
38-
objref:
39-
kind: Certificate
40-
group: cert-manager.io
41-
version: v1
42-
name: serving-cert # this name should match the one in certificate.yaml
43-
- name: SERVICE_NAMESPACE # namespace of the service
44-
objref:
45-
kind: Service
46-
version: v1
47-
name: webhook-service
48-
fieldref:
49-
fieldpath: metadata.namespace
50-
- name: SERVICE_NAME
51-
objref:
52-
kind: Service
53-
version: v1
54-
name: webhook-service
24+
- path: webhookcainjection_patch.yaml
5525

56-
configurations:
57-
- kustomizeconfig.yaml
26+
replacements:
27+
- source: # Add cert-manager annotation to ValidatingWebhookConfiguration, MutatingWebhookConfiguration and CRDs
28+
kind: Certificate
29+
group: cert-manager.io
30+
version: v1
31+
name: serving-cert # this name should match the one in certificate.yaml
32+
fieldPath: .metadata.namespace # namespace of the certificate CR
33+
targets:
34+
- select:
35+
kind: ValidatingWebhookConfiguration
36+
fieldPaths:
37+
- .metadata.annotations.[cert-manager.io/inject-ca-from]
38+
options:
39+
delimiter: '/'
40+
index: 0
41+
create: true
42+
- select:
43+
kind: MutatingWebhookConfiguration
44+
fieldPaths:
45+
- .metadata.annotations.[cert-manager.io/inject-ca-from]
46+
options:
47+
delimiter: '/'
48+
index: 0
49+
create: true
50+
- select:
51+
kind: CustomResourceDefinition
52+
fieldPaths:
53+
- .metadata.annotations.[cert-manager.io/inject-ca-from]
54+
options:
55+
delimiter: '/'
56+
index: 0
57+
create: true
58+
- source:
59+
kind: Certificate
60+
group: cert-manager.io
61+
version: v1
62+
name: serving-cert # this name should match the one in certificate.yaml
63+
fieldPath: .metadata.name
64+
targets:
65+
- select:
66+
kind: ValidatingWebhookConfiguration
67+
fieldPaths:
68+
- .metadata.annotations.[cert-manager.io/inject-ca-from]
69+
options:
70+
delimiter: '/'
71+
index: 1
72+
create: true
73+
- select:
74+
kind: MutatingWebhookConfiguration
75+
fieldPaths:
76+
- .metadata.annotations.[cert-manager.io/inject-ca-from]
77+
options:
78+
delimiter: '/'
79+
index: 1
80+
create: true
81+
- select:
82+
kind: CustomResourceDefinition
83+
fieldPaths:
84+
- .metadata.annotations.[cert-manager.io/inject-ca-from]
85+
options:
86+
delimiter: '/'
87+
index: 1
88+
create: true
89+
- source: # Add cert-manager annotation to the webhook Service
90+
kind: Service
91+
version: v1
92+
name: webhook-service
93+
fieldPath: .metadata.name # namespace of the service
94+
targets:
95+
- select:
96+
kind: Certificate
97+
group: cert-manager.io
98+
version: v1
99+
fieldPaths:
100+
- .spec.dnsNames.0
101+
- .spec.dnsNames.1
102+
options:
103+
delimiter: '.'
104+
index: 0
105+
create: true
106+
- source:
107+
kind: Service
108+
version: v1
109+
name: webhook-service
110+
fieldPath: .metadata.namespace # namespace of the service
111+
targets:
112+
- select:
113+
kind: Certificate
114+
group: cert-manager.io
115+
version: v1
116+
fieldPaths:
117+
- .spec.dnsNames.0
118+
- .spec.dnsNames.1
119+
options:
120+
delimiter: '.'
121+
index: 1
122+
create: true

bootstrap/kubeadm/config/default/kustomizeconfig.yaml

Lines changed: 0 additions & 4 deletions
This file was deleted.

bootstrap/kubeadm/config/default/manager_webhook_patch.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ spec:
1919
volumes:
2020
- name: cert
2121
secret:
22-
secretName: $(SERVICE_NAME)-cert
22+
secretName: webhook-service-cert

bootstrap/kubeadm/config/default/webhookcainjection_patch.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ kind: MutatingWebhookConfiguration
44
metadata:
55
name: mutating-webhook-configuration
66
annotations:
7-
cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
7+
cert-manager.io/inject-ca-from: CERTIFICATE_NAMESPACE/CERTIFICATE_NAME
88
---
99
apiVersion: admissionregistration.k8s.io/v1
1010
kind: ValidatingWebhookConfiguration
1111
metadata:
1212
name: validating-webhook-configuration
1313
annotations:
14-
cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
14+
cert-manager.io/inject-ca-from: CERTIFICATE_NAMESPACE/CERTIFICATE_NAME

0 commit comments

Comments
 (0)