Skip to content

Commit 4b4124d

Browse files
Refine CA injection setup for ConversionWebhook in Kubebuilder scaffold
In PR kubernetes-sigs#4123, cert-manager CA injection annotations were added directly in the centralized config for ConversionWebhook: - Fields such as `fieldPath: .metadata.namespace` and `fieldPath: .metadata.name` were added to inject the CA into each CRD’s ConversionWebhook. However, this setup is redundant for ConversionWebhooks. Each CRD with a ConversionWebhook already receives the necessary CA injection through a patch managed by cert-manager, making a centralized configuration unnecessary. This commit removes the centralized CA injection configuration for ConversionWebhook to simplify the scaffold and prevent potential duplicate injection issues. Fixes: - Ensures CA injection is handled on a per-CRD basis by cert-manager patches, providing clear, efficient CA management for ConversionWebhooks.
1 parent 83a7738 commit 4b4124d

File tree

10 files changed

+3
-282
lines changed

10 files changed

+3
-282
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ jobs:
8383
# Uncomment only ValidatingWebhookConfiguration
8484
# from cert-manager replaces
8585
sed -i '50,80s/^#//' $KUSTOMIZATION_FILE_PATH
86-
sed -i '144,177s/^#//' $KUSTOMIZATION_FILE_PATH
86+
sed -i '113,146s/^#//' $KUSTOMIZATION_FILE_PATH
8787
cd testdata/project-v4-with-plugins/
8888
go mod tidy
8989
@@ -122,11 +122,11 @@ jobs:
122122
run: |
123123
KUSTOMIZATION_FILE_PATH="testdata/project-v4-multigroup/config/default/kustomization.yaml"
124124
sed -i '25s/^#//' $KUSTOMIZATION_FILE_PATH
125-
sed -i '50,177s/^#//' $KUSTOMIZATION_FILE_PATH
125+
sed -i '50,146s/^#//' $KUSTOMIZATION_FILE_PATH
126126
cd testdata/project-v4-multigroup
127127
go mod tidy
128128
129129
- name: Testing make test-e2e for project-v4-multigroup
130130
working-directory: testdata/project-v4-multigroup/
131131
run: |
132-
make test-e2e
132+
make test-e2e

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

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -110,37 +110,6 @@ replacements:
110110
index: 1
111111
create: true
112112

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-
144113
- source: # Uncomment the following block if you enable cert-manager
145114
kind: Service
146115
version: v1

docs/book/src/getting-started/testdata/project/config/default/kustomization.yaml

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -110,37 +110,6 @@ patches:
110110
# index: 1
111111
# create: true
112112
#
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-
#
144113
# - source: # Uncomment the following block if you enable cert-manager
145114
# kind: Service
146115
# version: v1

docs/book/src/multiversion-tutorial/testdata/project/config/default/kustomization.yaml

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -110,37 +110,6 @@ replacements:
110110
index: 1
111111
create: true
112112

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-
144113
- source: # Uncomment the following block if you enable cert-manager
145114
kind: Service
146115
version: v1

hack/docs/internal/cronjob-tutorial/sample.go

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -96,37 +96,6 @@ const DefaultKustomization = `#replacements:
9696
# index: 1
9797
# create: true
9898
#
99-
# - source: # Uncomment the following block if you have a ConversionWebhook (--conversion)
100-
# kind: Certificate
101-
# group: cert-manager.io
102-
# version: v1
103-
# name: serving-cert # This name should match the one in certificate.yaml
104-
# fieldPath: .metadata.namespace # Namespace of the certificate CR
105-
# targets:
106-
# - select:
107-
# kind: CustomResourceDefinition
108-
# fieldPaths:
109-
# - .metadata.annotations.[cert-manager.io/inject-ca-from]
110-
# options:
111-
# delimiter: '/'
112-
# index: 0
113-
# create: true
114-
# - source:
115-
# kind: Certificate
116-
# group: cert-manager.io
117-
# version: v1
118-
# name: serving-cert # This name should match the one in certificate.yaml
119-
# fieldPath: .metadata.name
120-
# targets:
121-
# - select:
122-
# kind: CustomResourceDefinition
123-
# fieldPaths:
124-
# - .metadata.annotations.[cert-manager.io/inject-ca-from]
125-
# options:
126-
# delimiter: '/'
127-
# index: 1
128-
# create: true
129-
#
13099
# - source: # Uncomment the following block if you enable cert-manager
131100
# kind: Service
132101
# version: v1

pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/kdefault/kustomization.go

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -155,37 +155,6 @@ patches:
155155
# index: 1
156156
# create: true
157157
#
158-
# - source: # Uncomment the following block if you have a ConversionWebhook (--conversion)
159-
# kind: Certificate
160-
# group: cert-manager.io
161-
# version: v1
162-
# name: serving-cert # This name should match the one in certificate.yaml
163-
# fieldPath: .metadata.namespace # Namespace of the certificate CR
164-
# targets:
165-
# - select:
166-
# kind: CustomResourceDefinition
167-
# fieldPaths:
168-
# - .metadata.annotations.[cert-manager.io/inject-ca-from]
169-
# options:
170-
# delimiter: '/'
171-
# index: 0
172-
# create: true
173-
# - source:
174-
# kind: Certificate
175-
# group: cert-manager.io
176-
# version: v1
177-
# name: serving-cert # This name should match the one in certificate.yaml
178-
# fieldPath: .metadata.name
179-
# targets:
180-
# - select:
181-
# kind: CustomResourceDefinition
182-
# fieldPaths:
183-
# - .metadata.annotations.[cert-manager.io/inject-ca-from]
184-
# options:
185-
# delimiter: '/'
186-
# index: 1
187-
# create: true
188-
#
189158
# - source: # Uncomment the following block if you enable cert-manager
190159
# kind: Service
191160
# version: v1

test/e2e/v4/generate_test.go

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -287,37 +287,6 @@ const certManagerTarget = `#replacements:
287287
# index: 1
288288
# create: true
289289
#
290-
# - source: # Uncomment the following block if you have a ConversionWebhook (--conversion)
291-
# kind: Certificate
292-
# group: cert-manager.io
293-
# version: v1
294-
# name: serving-cert # This name should match the one in certificate.yaml
295-
# fieldPath: .metadata.namespace # Namespace of the certificate CR
296-
# targets:
297-
# - select:
298-
# kind: CustomResourceDefinition
299-
# fieldPaths:
300-
# - .metadata.annotations.[cert-manager.io/inject-ca-from]
301-
# options:
302-
# delimiter: '/'
303-
# index: 0
304-
# create: true
305-
# - source:
306-
# kind: Certificate
307-
# group: cert-manager.io
308-
# version: v1
309-
# name: serving-cert # This name should match the one in certificate.yaml
310-
# fieldPath: .metadata.name
311-
# targets:
312-
# - select:
313-
# kind: CustomResourceDefinition
314-
# fieldPaths:
315-
# - .metadata.annotations.[cert-manager.io/inject-ca-from]
316-
# options:
317-
# delimiter: '/'
318-
# index: 1
319-
# create: true
320-
#
321290
# - source: # Uncomment the following block if you enable cert-manager
322291
# kind: Service
323292
# version: v1

testdata/project-v4-multigroup/config/default/kustomization.yaml

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -110,37 +110,6 @@ patches:
110110
# index: 1
111111
# create: true
112112
#
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-
#
144113
# - source: # Uncomment the following block if you enable cert-manager
145114
# kind: Service
146115
# version: v1

testdata/project-v4-with-plugins/config/default/kustomization.yaml

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -110,37 +110,6 @@ patches:
110110
# index: 1
111111
# create: true
112112
#
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-
#
144113
# - source: # Uncomment the following block if you enable cert-manager
145114
# kind: Service
146115
# version: v1

testdata/project-v4/config/default/kustomization.yaml

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -110,37 +110,6 @@ patches:
110110
# index: 1
111111
# create: true
112112
#
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-
#
144113
# - source: # Uncomment the following block if you enable cert-manager
145114
# kind: Service
146115
# version: v1

0 commit comments

Comments
 (0)