Skip to content

Commit 7527b0d

Browse files
šŸ› (go/v4,kustomize/v2): Fix problems by simplify scaffold and removing webhookcainjection_patch. Clarifying replacements for cert-manager (#4123)
fix issues by simplifying the scaffold. Removes webhookcainjection_patch and clarify replacements. - Removed config/default/webhookcainjection_patch.yaml to streamline the scaffold. - Clarified replacements blocks in kustomization.yaml for easier understanding. Each block is now labeled with instructions for uncommenting based on specific webhook scenarios (ValidatingWebhook, DefaultingWebhook, ConvertingWebhook).
1 parent eedee67 commit 7527b0d

File tree

20 files changed

+1147
-1132
lines changed

20 files changed

+1147
-1132
lines changed

ā€Ž.github/workflows/test-e2e-samples.yml

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ jobs:
4141
run: |
4242
KUSTOMIZATION_FILE_PATH="testdata/project-v4/config/default/kustomization.yaml"
4343
sed -i '25s/^#//' $KUSTOMIZATION_FILE_PATH
44-
sed -i '51s/^#//' $KUSTOMIZATION_FILE_PATH
45-
sed -i '55,151s/^#//' $KUSTOMIZATION_FILE_PATH
44+
sed -i '50,177s/^#//' $KUSTOMIZATION_FILE_PATH
4645
cd testdata/project-v4/
4746
go mod tidy
4847
@@ -81,17 +80,10 @@ jobs:
8180
run: |
8281
KUSTOMIZATION_FILE_PATH="testdata/project-v4-with-plugins/config/default/kustomization.yaml"
8382
sed -i '25s/^#//' $KUSTOMIZATION_FILE_PATH
84-
sed -i '51s/^#//' $KUSTOMIZATION_FILE_PATH
8583
# Uncomment only ValidatingWebhookConfiguration
8684
# from cert-manager replaces
87-
sed -i '55,70s/^#//' $KUSTOMIZATION_FILE_PATH
88-
sed -i '79,101s/^#//' $KUSTOMIZATION_FILE_PATH
89-
sed -i '110,151s/^#//' $KUSTOMIZATION_FILE_PATH
90-
# Comment the injection for MutatingWebhookConfiguration
91-
# Fixme: We should not scaffold or it should be commented
92-
# by default when only validation webhooks are scaffolded
93-
WEBHOOK_INJECTION_FILE_PATH="testdata/project-v4-with-plugins/config/default/webhookcainjection_patch.yaml"
94-
sed -i '3,11s/^/#/' $WEBHOOK_INJECTION_FILE_PATH
85+
sed -i '50,80s/^#//' $KUSTOMIZATION_FILE_PATH
86+
sed -i '144,177s/^#//' $KUSTOMIZATION_FILE_PATH
9587
cd testdata/project-v4-with-plugins/
9688
go mod tidy
9789
@@ -130,8 +122,7 @@ jobs:
130122
run: |
131123
KUSTOMIZATION_FILE_PATH="testdata/project-v4-multigroup/config/default/kustomization.yaml"
132124
sed -i '25s/^#//' $KUSTOMIZATION_FILE_PATH
133-
sed -i '51s/^#//' $KUSTOMIZATION_FILE_PATH
134-
sed -i '55,151s/^#//' $KUSTOMIZATION_FILE_PATH
125+
sed -i '50,177s/^#//' $KUSTOMIZATION_FILE_PATH
135126
cd testdata/project-v4-multigroup
136127
go mod tidy
137128

ā€Ždocs/book/src/cronjob-tutorial/cert-manager.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,3 @@ This is the [kustomize](https://github.com/kubernetes-sigs/kustomize) patch we
2424
used for annotating the [`MutatingWebhookConfiguration`](https://pkg.go.dev/k8s.io/api/admissionregistration/v1#MutatingWebhookConfiguration)
2525
/ [`ValidatingWebhookConfiguration`](https://pkg.go.dev/k8s.io/api/admissionregistration/v1#ValidatingWebhookConfiguration) objects.
2626

27-
```yaml
28-
{{#include ./testdata/project/config/default/webhookcainjection_patch.yaml}}
29-
```

ā€Ždocs/book/src/cronjob-tutorial/testdata/project/config/default/kustomization.yaml

Lines changed: 127 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -45,107 +45,133 @@ patches:
4545
# crd/kustomization.yaml
4646
- path: manager_webhook_patch.yaml
4747

48-
# [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER'.
49-
# Uncomment 'CERTMANAGER' sections in crd/kustomization.yaml to enable the CA injection in the admission webhooks.
50-
# 'CERTMANAGER' needs to be enabled to use ca injection
51-
- path: webhookcainjection_patch.yaml
52-
5348
# [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER' prefix.
5449
# Uncomment the following replacements to add the cert-manager CA injection annotations
5550
replacements:
56-
- source: # Add cert-manager annotation to ValidatingWebhookConfiguration, MutatingWebhookConfiguration and CRDs
57-
kind: Certificate
58-
group: cert-manager.io
59-
version: v1
60-
name: serving-cert # this name should match the one in certificate.yaml
61-
fieldPath: .metadata.namespace # namespace of the certificate CR
62-
targets:
63-
- select:
64-
kind: ValidatingWebhookConfiguration
65-
fieldPaths:
66-
- .metadata.annotations.[cert-manager.io/inject-ca-from]
67-
options:
68-
delimiter: '/'
69-
index: 0
70-
create: true
71-
- select:
72-
kind: MutatingWebhookConfiguration
73-
fieldPaths:
74-
- .metadata.annotations.[cert-manager.io/inject-ca-from]
75-
options:
76-
delimiter: '/'
77-
index: 0
78-
create: true
79-
- select:
80-
kind: CustomResourceDefinition
81-
fieldPaths:
82-
- .metadata.annotations.[cert-manager.io/inject-ca-from]
83-
options:
84-
delimiter: '/'
85-
index: 0
86-
create: true
87-
- source:
88-
kind: Certificate
89-
group: cert-manager.io
90-
version: v1
91-
name: serving-cert # this name should match the one in certificate.yaml
92-
fieldPath: .metadata.name
93-
targets:
94-
- select:
95-
kind: ValidatingWebhookConfiguration
96-
fieldPaths:
97-
- .metadata.annotations.[cert-manager.io/inject-ca-from]
98-
options:
99-
delimiter: '/'
100-
index: 1
101-
create: true
102-
- select:
103-
kind: MutatingWebhookConfiguration
104-
fieldPaths:
105-
- .metadata.annotations.[cert-manager.io/inject-ca-from]
106-
options:
107-
delimiter: '/'
108-
index: 1
109-
create: true
110-
- select:
111-
kind: CustomResourceDefinition
112-
fieldPaths:
113-
- .metadata.annotations.[cert-manager.io/inject-ca-from]
114-
options:
115-
delimiter: '/'
116-
index: 1
117-
create: true
118-
- source: # Add cert-manager annotation to the webhook Service
119-
kind: Service
120-
version: v1
121-
name: webhook-service
122-
fieldPath: .metadata.name # namespace of the service
123-
targets:
124-
- select:
125-
kind: Certificate
126-
group: cert-manager.io
127-
version: v1
128-
fieldPaths:
129-
- .spec.dnsNames.0
130-
- .spec.dnsNames.1
131-
options:
132-
delimiter: '.'
133-
index: 0
134-
create: true
135-
- source:
136-
kind: Service
137-
version: v1
138-
name: webhook-service
139-
fieldPath: .metadata.namespace # namespace of the service
140-
targets:
141-
- select:
142-
kind: Certificate
143-
group: cert-manager.io
144-
version: v1
145-
fieldPaths:
146-
- .spec.dnsNames.0
147-
- .spec.dnsNames.1
148-
options:
149-
delimiter: '.'
150-
index: 1
151-
create: true
51+
- source: # Uncomment the following block if you have a ValidatingWebhook (--programmatic-validation)
52+
kind: Certificate
53+
group: cert-manager.io
54+
version: v1
55+
name: serving-cert # This name should match the one in certificate.yaml
56+
fieldPath: .metadata.namespace # Namespace of the certificate CR
57+
targets:
58+
- select:
59+
kind: ValidatingWebhookConfiguration
60+
fieldPaths:
61+
- .metadata.annotations.[cert-manager.io/inject-ca-from]
62+
options:
63+
delimiter: '/'
64+
index: 0
65+
create: true
66+
- source:
67+
kind: Certificate
68+
group: cert-manager.io
69+
version: v1
70+
name: serving-cert # This name should match the one in certificate.yaml
71+
fieldPath: .metadata.name
72+
targets:
73+
- select:
74+
kind: ValidatingWebhookConfiguration
75+
fieldPaths:
76+
- .metadata.annotations.[cert-manager.io/inject-ca-from]
77+
options:
78+
delimiter: '/'
79+
index: 1
80+
create: true
81+
82+
- source: # Uncomment the following block if you have a DefaultingWebhook (--defaulting )
83+
kind: Certificate
84+
group: cert-manager.io
85+
version: v1
86+
name: serving-cert # This name should match the one in certificate.yaml
87+
fieldPath: .metadata.namespace # Namespace of the certificate CR
88+
targets:
89+
- select:
90+
kind: MutatingWebhookConfiguration
91+
fieldPaths:
92+
- .metadata.annotations.[cert-manager.io/inject-ca-from]
93+
options:
94+
delimiter: '/'
95+
index: 0
96+
create: true
97+
- source:
98+
kind: Certificate
99+
group: cert-manager.io
100+
version: v1
101+
name: serving-cert # This name should match the one in certificate.yaml
102+
fieldPath: .metadata.name
103+
targets:
104+
- select:
105+
kind: MutatingWebhookConfiguration
106+
fieldPaths:
107+
- .metadata.annotations.[cert-manager.io/inject-ca-from]
108+
options:
109+
delimiter: '/'
110+
index: 1
111+
create: true
112+
113+
- source: # Uncomment the following block if you have a ConversionWebhook (--conversion)
114+
kind: Certificate
115+
group: cert-manager.io
116+
version: v1
117+
name: serving-cert # This name should match the one in certificate.yaml
118+
fieldPath: .metadata.namespace # Namespace of the certificate CR
119+
targets:
120+
- select:
121+
kind: CustomResourceDefinition
122+
fieldPaths:
123+
- .metadata.annotations.[cert-manager.io/inject-ca-from]
124+
options:
125+
delimiter: '/'
126+
index: 0
127+
create: true
128+
- source:
129+
kind: Certificate
130+
group: cert-manager.io
131+
version: v1
132+
name: serving-cert # This name should match the one in certificate.yaml
133+
fieldPath: .metadata.name
134+
targets:
135+
- select:
136+
kind: CustomResourceDefinition
137+
fieldPaths:
138+
- .metadata.annotations.[cert-manager.io/inject-ca-from]
139+
options:
140+
delimiter: '/'
141+
index: 1
142+
create: true
143+
144+
- source: # Uncomment the following block if you enable cert-manager
145+
kind: Service
146+
version: v1
147+
name: webhook-service
148+
fieldPath: .metadata.name # Name of the service
149+
targets:
150+
- select:
151+
kind: Certificate
152+
group: cert-manager.io
153+
version: v1
154+
fieldPaths:
155+
- .spec.dnsNames.0
156+
- .spec.dnsNames.1
157+
options:
158+
delimiter: '.'
159+
index: 0
160+
create: true
161+
- source:
162+
kind: Service
163+
version: v1
164+
name: webhook-service
165+
fieldPath: .metadata.namespace # Namespace of the service
166+
targets:
167+
- select:
168+
kind: Certificate
169+
group: cert-manager.io
170+
version: v1
171+
fieldPaths:
172+
- .spec.dnsNames.0
173+
- .spec.dnsNames.1
174+
options:
175+
delimiter: '.'
176+
index: 1
177+
create: true

ā€Ždocs/book/src/cronjob-tutorial/testdata/project/config/default/webhookcainjection_patch.yaml

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

0 commit comments

Comments
Ā (0)