Skip to content

Commit 1b5cddf

Browse files
fix ca injection - wip
1 parent c7fce39 commit 1b5cddf

File tree

49 files changed

+1429
-507
lines changed

Some content is hidden

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

49 files changed

+1429
-507
lines changed

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ jobs:
4141
run: |
4242
KUSTOMIZATION_FILE_PATH="testdata/project-v4/config/default/kustomization.yaml"
4343
sed -i '25s/^#//' $KUSTOMIZATION_FILE_PATH
44-
sed -i '50,177s/^#//' $KUSTOMIZATION_FILE_PATH
44+
# Uncomment all cert-manager injections
45+
sed -i '50,172s/^#//' $KUSTOMIZATION_FILE_PATH
46+
sed -i '174,198s/^#//' $KUSTOMIZATION_FILE_PATH
4547
cd testdata/project-v4/
4648
go mod tidy
4749
@@ -81,9 +83,12 @@ jobs:
8183
KUSTOMIZATION_FILE_PATH="testdata/project-v4-with-plugins/config/default/kustomization.yaml"
8284
sed -i '25s/^#//' $KUSTOMIZATION_FILE_PATH
8385
# Uncomment only ValidatingWebhookConfiguration
84-
# from cert-manager replaces
85-
sed -i '50,80s/^#//' $KUSTOMIZATION_FILE_PATH
86-
sed -i '144,177s/^#//' $KUSTOMIZATION_FILE_PATH
86+
# from cert-manager replaces; we are leaving defaulting uncommented
87+
# since this sample has no defaulting webhooks
88+
sed -i '50,155s/^#//' $KUSTOMIZATION_FILE_PATH
89+
# Uncomment only --conversion webhooks CA injection
90+
sed -i '144,163s/^#//' $KUSTOMIZATION_FILE_PATH
91+
sed -i '165,180s/^#//' $KUSTOMIZATION_FILE_PATH
8792
cd testdata/project-v4-with-plugins/
8893
go mod tidy
8994

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,10 @@ resources:
66
# +kubebuilder:scaffold:crdkustomizeresource
77

88
patches:
9-
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix.
9+
# [WEBHOOK] To enable the webhooks, uncomment all the sections with [WEBHOOK] prefix.
1010
# patches here are for enabling the conversion webhook for each CRD
1111
# +kubebuilder:scaffold:crdkustomizewebhookpatch
1212

13-
# [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix.
14-
# patches here are for enabling the CA injection for each CRD
15-
# +kubebuilder:scaffold:crdkustomizecainjectionpatch
16-
1713
# [WEBHOOK] To enable webhook, uncomment the following section
1814
# the following config is for teaching kustomize how to do kustomization for CRDs.
1915
#configurations:

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

Lines changed: 39 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,41 @@ patches:
4848
# [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER' prefix.
4949
# Uncomment the following replacements to add the cert-manager CA injection annotations
5050
replacements:
51+
- source: # Uncomment the following block if you enable cert-manager
52+
kind: Service
53+
version: v1
54+
name: webhook-service
55+
fieldPath: .metadata.name # Name of the service
56+
targets:
57+
- select:
58+
kind: Certificate
59+
group: cert-manager.io
60+
version: v1
61+
fieldPaths:
62+
- .spec.dnsNames.0
63+
- .spec.dnsNames.1
64+
options:
65+
delimiter: '.'
66+
index: 0
67+
create: true
68+
- source:
69+
kind: Service
70+
version: v1
71+
name: webhook-service
72+
fieldPath: .metadata.namespace # Namespace of the service
73+
targets:
74+
- select:
75+
kind: Certificate
76+
group: cert-manager.io
77+
version: v1
78+
fieldPaths:
79+
- .spec.dnsNames.0
80+
- .spec.dnsNames.1
81+
options:
82+
delimiter: '.'
83+
index: 1
84+
create: true
85+
5186
- source: # Uncomment the following block if you have a ValidatingWebhook (--programmatic-validation)
5287
kind: Certificate
5388
group: cert-manager.io
@@ -116,62 +151,13 @@ replacements:
116151
# version: v1
117152
# name: serving-cert # This name should match the one in certificate.yaml
118153
# 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
154+
# targets: # Do not remove or uncomment the following scaffold marker; required to generate code for target CRD.
155+
# +kubebuilder:scaffold:crdcainjectionnamespace
128156
# - source:
129157
# kind: Certificate
130158
# group: cert-manager.io
131159
# version: v1
132160
# name: serving-cert # This name should match the one in certificate.yaml
133161
# 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
162+
# targets: # Do not remove or uncomment the following scaffold marker; required to generate code for target CRD.
163+
# +kubebuilder:scaffold:crdcainjectioncertificate

docs/book/src/cronjob-tutorial/testdata/project/dist/install.yaml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,6 @@ metadata:
1414
controller-gen.kubebuilder.io/version: v0.16.4
1515
name: cronjobs.batch.tutorial.kubebuilder.io
1616
spec:
17-
conversion:
18-
strategy: Webhook
19-
webhook:
20-
clientConfig:
21-
service:
22-
name: project-webhook-service
23-
namespace: project-system
24-
path: /convert
25-
conversionReviewVersions:
26-
- v1
2717
group: batch.tutorial.kubebuilder.io
2818
names:
2919
kind: CronJob

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,10 @@ resources:
66
# +kubebuilder:scaffold:crdkustomizeresource
77

88
patches:
9-
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix.
9+
# [WEBHOOK] To enable the webhooks, uncomment all the sections with [WEBHOOK] prefix.
1010
# patches here are for enabling the conversion webhook for each CRD
1111
# +kubebuilder:scaffold:crdkustomizewebhookpatch
1212

13-
# [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix.
14-
# patches here are for enabling the CA injection for each CRD
15-
# +kubebuilder:scaffold:crdkustomizecainjectionpatch
16-
1713
# [WEBHOOK] To enable webhook, uncomment the following section
1814
# the following config is for teaching kustomize how to do kustomization for CRDs.
1915
#configurations:

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

Lines changed: 38 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -48,46 +48,50 @@ patches:
4848
# [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER' prefix.
4949
# Uncomment the following replacements to add the cert-manager CA injection annotations
5050
#replacements:
51-
# - source: # Uncomment the following block if you have a ValidatingWebhook (--programmatic-validation)
52-
# kind: Certificate
53-
# group: cert-manager.io
51+
# - source: # Uncomment the following block if you enable cert-manager
52+
# kind: Service
5453
# version: v1
55-
# name: serving-cert # This name should match the one in certificate.yaml
56-
# fieldPath: .metadata.namespace # Namespace of the certificate CR
54+
# name: webhook-service
55+
# fieldPath: .metadata.name # Name of the service
5756
# targets:
5857
# - select:
59-
# kind: ValidatingWebhookConfiguration
58+
# kind: Certificate
59+
# group: cert-manager.io
60+
# version: v1
6061
# fieldPaths:
61-
# - .metadata.annotations.[cert-manager.io/inject-ca-from]
62+
# - .spec.dnsNames.0
63+
# - .spec.dnsNames.1
6264
# options:
63-
# delimiter: '/'
65+
# delimiter: '.'
6466
# index: 0
6567
# create: true
6668
# - source:
67-
# kind: Certificate
68-
# group: cert-manager.io
69+
# kind: Service
6970
# version: v1
70-
# name: serving-cert # This name should match the one in certificate.yaml
71-
# fieldPath: .metadata.name
71+
# name: webhook-service
72+
# fieldPath: .metadata.namespace # Namespace of the service
7273
# targets:
7374
# - select:
74-
# kind: ValidatingWebhookConfiguration
75+
# kind: Certificate
76+
# group: cert-manager.io
77+
# version: v1
7578
# fieldPaths:
76-
# - .metadata.annotations.[cert-manager.io/inject-ca-from]
79+
# - .spec.dnsNames.0
80+
# - .spec.dnsNames.1
7781
# options:
78-
# delimiter: '/'
82+
# delimiter: '.'
7983
# index: 1
8084
# create: true
8185
#
82-
# - source: # Uncomment the following block if you have a DefaultingWebhook (--defaulting )
86+
# - source: # Uncomment the following block if you have a ValidatingWebhook (--programmatic-validation)
8387
# kind: Certificate
8488
# group: cert-manager.io
8589
# version: v1
8690
# name: serving-cert # This name should match the one in certificate.yaml
8791
# fieldPath: .metadata.namespace # Namespace of the certificate CR
8892
# targets:
8993
# - select:
90-
# kind: MutatingWebhookConfiguration
94+
# kind: ValidatingWebhookConfiguration
9195
# fieldPaths:
9296
# - .metadata.annotations.[cert-manager.io/inject-ca-from]
9397
# options:
@@ -102,23 +106,23 @@ patches:
102106
# fieldPath: .metadata.name
103107
# targets:
104108
# - select:
105-
# kind: MutatingWebhookConfiguration
109+
# kind: ValidatingWebhookConfiguration
106110
# fieldPaths:
107111
# - .metadata.annotations.[cert-manager.io/inject-ca-from]
108112
# options:
109113
# delimiter: '/'
110114
# index: 1
111115
# create: true
112116
#
113-
# - source: # Uncomment the following block if you have a ConversionWebhook (--conversion)
117+
# - source: # Uncomment the following block if you have a DefaultingWebhook (--defaulting )
114118
# kind: Certificate
115119
# group: cert-manager.io
116120
# version: v1
117121
# name: serving-cert # This name should match the one in certificate.yaml
118122
# fieldPath: .metadata.namespace # Namespace of the certificate CR
119123
# targets:
120124
# - select:
121-
# kind: CustomResourceDefinition
125+
# kind: MutatingWebhookConfiguration
122126
# fieldPaths:
123127
# - .metadata.annotations.[cert-manager.io/inject-ca-from]
124128
# options:
@@ -133,45 +137,27 @@ patches:
133137
# fieldPath: .metadata.name
134138
# targets:
135139
# - select:
136-
# kind: CustomResourceDefinition
140+
# kind: MutatingWebhookConfiguration
137141
# fieldPaths:
138142
# - .metadata.annotations.[cert-manager.io/inject-ca-from]
139143
# options:
140144
# delimiter: '/'
141145
# index: 1
142146
# create: true
143147
#
144-
# - source: # Uncomment the following block if you enable cert-manager
145-
# kind: Service
148+
# - source: # Uncomment the following block if you have a ConversionWebhook (--conversion)
149+
# kind: Certificate
150+
# group: cert-manager.io
146151
# 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
152+
# name: serving-cert # This name should match the one in certificate.yaml
153+
# fieldPath: .metadata.namespace # Namespace of the certificate CR
154+
# targets: # Do not remove or uncomment the following scaffold marker; required to generate code for target CRD.
155+
# +kubebuilder:scaffold:crdcainjectionnamespace
161156
# - source:
162-
# kind: Service
157+
# kind: Certificate
158+
# group: cert-manager.io
163159
# 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
160+
# name: serving-cert # This name should match the one in certificate.yaml
161+
# fieldPath: .metadata.name
162+
# targets: # Do not remove or uncomment the following scaffold marker; required to generate code for target CRD.
163+
# +kubebuilder:scaffold:crdcainjectioncertificate

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,11 @@ resources:
66
# +kubebuilder:scaffold:crdkustomizeresource
77

88
patches:
9-
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix.
9+
# [WEBHOOK] To enable the webhooks, uncomment all the sections with [WEBHOOK] prefix.
1010
# patches here are for enabling the conversion webhook for each CRD
1111
- path: patches/webhook_in_cronjobs.yaml
1212
# +kubebuilder:scaffold:crdkustomizewebhookpatch
1313

14-
# [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix.
15-
# patches here are for enabling the CA injection for each CRD
16-
#- path: patches/cainjection_in_cronjobs.yaml
17-
# +kubebuilder:scaffold:crdkustomizecainjectionpatch
18-
1914
# [WEBHOOK] To enable webhook, uncomment the following section
2015
# the following config is for teaching kustomize how to do kustomization for CRDs.
2116
configurations:

docs/book/src/multiversion-tutorial/testdata/project/config/crd/patches/cainjection_in_cronjobs.yaml

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

0 commit comments

Comments
 (0)