Skip to content

Commit 0fcbbdd

Browse files
✨ Simplify scaffold by removing webhookcainjection_patch and clarifying 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 c0ba5ce commit 0fcbbdd

File tree

19 files changed

+1276
-1231
lines changed

19 files changed

+1276
-1231
lines changed

.github/workflows/test-e2e-samples.yml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ jobs:
3838
run: |
3939
KUSTOMIZATION_FILE_PATH="testdata/project-v4/config/default/kustomization.yaml"
4040
sed -i '25s/^#//' $KUSTOMIZATION_FILE_PATH
41-
sed -i '51s/^#//' $KUSTOMIZATION_FILE_PATH
42-
sed -i '55,151s/^#//' $KUSTOMIZATION_FILE_PATH
41+
sed -i '50,177s/^#//' $KUSTOMIZATION_FILE_PATH
4342
cd testdata/project-v4/
4443
go mod tidy
4544
@@ -58,18 +57,10 @@ jobs:
5857
run: |
5958
KUSTOMIZATION_FILE_PATH="testdata/project-v4-with-deploy-image/config/default/kustomization.yaml"
6059
sed -i '25s/^#//' $KUSTOMIZATION_FILE_PATH
61-
sed -i '51s/^#//' $KUSTOMIZATION_FILE_PATH
6260
# Uncomment only ValidatingWebhookConfiguration
6361
# from cert-manager replaces
64-
sed -i '55,70s/^#//' $KUSTOMIZATION_FILE_PATH
65-
sed -i '55,70s/^#//' $KUSTOMIZATION_FILE_PATH
66-
sed -i '79,101s/^#//' $KUSTOMIZATION_FILE_PATH
67-
sed -i '110,151s/^#//' $KUSTOMIZATION_FILE_PATH
68-
# Comment the injection for MutatingWebhookConfiguration
69-
# Fixme: We should not scaffold or it should be commented
70-
# by default when only validation webhooks are scaffolded
71-
WEBHOOK_INJECTION_FILE_PATH="testdata/project-v4-with-deploy-image/config/default/webhookcainjection_patch.yaml"
72-
sed -i '3,11s/^/#/' $WEBHOOK_INJECTION_FILE_PATH
62+
sed -i '51,80s/^#//' $KUSTOMIZATION_FILE_PATH
63+
sed -i '144,177s/^#//' $KUSTOMIZATION_FILE_PATH
7364
cd testdata/project-v4-with-deploy-image/
7465
go mod tidy
7566

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 scaffold any webhook to inject CA into the webhook service
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)