Skip to content

Commit 541b0c0

Browse files
committed
OLM: do no use cert-manager
OLM provisions its own webhook certificates. Do not include cert-manager as a dependency when deploying with OLM. Rework the directory layout to use cert-manager only when using `make deploy`. Revert d4f87b0.
1 parent d4f87b0 commit 541b0c0

31 files changed

+135
-301
lines changed

Makefile

-2
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,6 @@ bundle: operator-sdk manifests kustomize ## Generate bundle manifests and metada
279279
cd config/manager-base && $(KUSTOMIZE) edit set image signer=$(SIGNER_IMG)
280280
cd config/webhook-server && $(KUSTOMIZE) edit set image webhook-server=$(WEBHOOK_IMG)
281281
kubectl kustomize config/manifests | ${OPERATOR_SDK} generate bundle $(BUNDLE_GEN_FLAGS)
282-
cp -r config/manifests/bundle-metadata/* bundle/metadata/
283282
${OPERATOR_SDK} bundle validate ./bundle
284283

285284
.PHONY: bundle-hub
@@ -294,7 +293,6 @@ bundle-hub: operator-sdk manifests kustomize ## Generate bundle manifests and me
294293
cd config/manager-base && $(KUSTOMIZE) edit set image signer=$(SIGNER_IMG)
295294
cd config/webhook-server && $(KUSTOMIZE) edit set image webhook-server=$(WEBHOOK_IMG)
296295
kubectl kustomize config/manifests-hub | ${OPERATOR_SDK} generate bundle --package kernel-module-management-hub $(BUNDLE_GEN_FLAGS)
297-
cp -r config/manifests-hub/bundle-metadata/* bundle/metadata/
298296
${OPERATOR_SDK} bundle validate ./bundle
299297

300298
.PHONY: bundle-build

config/certificate/kustomization.yaml

-8
This file was deleted.

config/crd-hub/kustomization.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@ kind: Kustomization
44
resources:
55
- bases/hub.kmm.sigs.x-k8s.io_managedclustermodules.yaml
66

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

1313
# [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix.
1414
# patches here are for enabling the CA injection for each CRD
15-
- path: patches/cainjection_in_managedclustermodules.yaml
15+
#- path: patches/cainjection_in_managedclustermodules.yaml
1616
#+kubebuilder:scaffold:crdkustomizecainjectionpatch
17-

config/crd-hub/patches/cainjection_in_managedclustermodules.yaml

-8
This file was deleted.

config/crd-hub/patches/webhook_in_managedclustermodules.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ spec:
1010
clientConfig:
1111
service:
1212
namespace: system
13-
name: webhook-server-service
13+
name: webhook-service
1414
path: /convert
1515
conversionReviewVersions:
1616
- v1

config/crd/kustomization.yaml

-5
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,9 @@ patches:
1414
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix.
1515
# patches here are for enabling the conversion webhook for each CRD
1616
#- path: patches/webhook_in_modules.yaml
17-
#- path: patches/webhook_in_managedclustermodules.yaml
1817
- path: patches/webhook_in_preflightvalidations.yaml
1918
#+kubebuilder:scaffold:crdkustomizewebhookpatch
2019

21-
# [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix.
22-
# patches here are for enabling the CA injection for each CRD
23-
- path: patches/cainjection_in_modules.yaml
24-
- path: patches/cainjection_in_preflightvalidations.yaml
2520
#+kubebuilder:scaffold:crdkustomizecainjectionpatch
2621

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

config/crd/patches/cainjection_in_modules.yaml

-8
This file was deleted.

config/crd/patches/cainjection_in_preflightvalidations.yaml

-8
This file was deleted.

config/crd/patches/webhook_in_modules.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ spec:
1010
clientConfig:
1111
service:
1212
namespace: system
13-
name: webhook-server-service
13+
name: webhook-service
1414
path: /convert
1515
conversionReviewVersions:
1616
- v1

config/crd/patches/webhook_in_preflightvalidations.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ spec:
1010
clientConfig:
1111
service:
1212
namespace: system
13-
name: webhook-server-service
13+
name: webhook-service
1414
path: /convert
1515
conversionReviewVersions:
1616
- v1beta2

config/default-hub/kustomization.yaml

+11-30
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@ kind: Kustomization
44
# Adds namespace to all resources.
55
namespace: kmm-operator-system
66

7-
# Value of this field is prepended to the
8-
# names of all resources, e.g. a deployment named
9-
# "wordpress" becomes "alices-wordpress".
10-
# Note that it should also match with the prefix (text before '-') of the namespace
11-
# field above.
127
namePrefix: kmm-operator-hub-
138

149
# Labels to add to all resources and selectors.
@@ -18,31 +13,13 @@ commonLabels:
1813
app.kubernetes.io/part-of: kmm
1914

2015
resources:
21-
- ../crd-hub
22-
- ../rbac-hub
23-
- ../manager-hub
24-
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
25-
# crd/kustomization.yaml
26-
- ../webhook-hub
27-
# [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER'. 'WEBHOOK' components are required.
28-
- ../certificate
29-
# [PROMETHEUS] To enable prometheus monitor, uncomment all sections with 'PROMETHEUS'.
30-
#- ../prometheus
31-
- ../webhook-server
16+
- ../deploy-hub
3217

33-
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in crd/kustomization.yaml
34-
patches:
35-
- path: webhookcainjection_patch.yaml
36-
- target:
37-
kind: Deployment
38-
name: webhook-server
39-
patch: |-
40-
- op: add
41-
path: /spec/template/spec/containers/0/args/-
42-
value: --enable-managedclustermodule
18+
components:
19+
- ../webhook-cert
4320

4421
replacements:
45-
# The following patches adds a directive for certmanager to inject CA into the CRD
22+
# Replacements below adjust the value of the cert-manager.io/inject-ca-from annotation in CRDs and webhook objects.
4623
- source:
4724
kind: Certificate
4825
fieldPath: metadata.namespace
@@ -52,12 +29,14 @@ replacements:
5229
fieldPaths:
5330
- metadata.annotations.[cert-manager.io/inject-ca-from]
5431
options:
32+
create: true
5533
delimiter: /
5634
- select:
5735
kind: ValidatingWebhookConfiguration
5836
fieldPaths:
5937
- metadata.annotations.[cert-manager.io/inject-ca-from]
6038
options:
39+
create: true
6140
delimiter: /
6241
- source:
6342
kind: Certificate
@@ -68,19 +47,21 @@ replacements:
6847
fieldPaths:
6948
- metadata.annotations.[cert-manager.io/inject-ca-from]
7049
options:
50+
create: true
7151
delimiter: /
7252
index: 1
7353
- select:
7454
kind: ValidatingWebhookConfiguration
7555
fieldPaths:
7656
- metadata.annotations.[cert-manager.io/inject-ca-from]
7757
options:
58+
create: true
7859
delimiter: /
7960
index: 1
80-
# Patch dnsNames in webhook Certificate
61+
# Replacements below adjust the DNS names of the webhook certificate based on the service name.
8162
- source:
8263
kind: Service
83-
name: webhook-server-service
64+
name: webhook-service
8465
fieldPath: metadata.name
8566
targets:
8667
- select:
@@ -91,7 +72,7 @@ replacements:
9172
delimiter: .
9273
- source:
9374
kind: Service
94-
name: webhook-server-service
75+
name: webhook-service
9576
fieldPath: metadata.namespace
9677
targets:
9778
- select:

config/default-hub/webhookcainjection_patch.yaml

-15
This file was deleted.

config/default/kustomization.yaml

+14-52
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
apiVersion: kustomize.config.k8s.io/v1beta1
22
kind: Kustomization
33

4+
resources:
5+
- ../deploy
6+
7+
components:
8+
- ../webhook-cert
9+
410
# Adds namespace to all resources.
511
namespace: kmm-operator-system
612

7-
# Value of this field is prepended to the
8-
# names of all resources, e.g. a deployment named
9-
# "wordpress" becomes "alices-wordpress".
10-
# Note that it should also match with the prefix (text before '-') of the namespace
11-
# field above.
1213
namePrefix: kmm-operator-
1314

1415
# Labels to add to all resources and selectors.
@@ -17,91 +18,52 @@ commonLabels:
1718
app.kubernetes.io/component: kmm
1819
app.kubernetes.io/part-of: kmm
1920

20-
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in crd/kustomization.yaml
21-
# [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER'. 'WEBHOOK' components are required.
22-
resources:
23-
- ../crd
24-
- ../rbac
25-
- ../manager
26-
- ../webhook
27-
- ../certificate
28-
# [PROMETHEUS] To enable prometheus monitor, uncomment all sections with 'PROMETHEUS'.
29-
#- ../prometheus
30-
- ../webhook-server
31-
32-
patches:
33-
- path: webhookcainjection_patch.yaml
34-
- target:
35-
kind: Deployment
36-
name: webhook-server
37-
patch: |-
38-
- op: add
39-
path: /spec/template/spec/containers/0/args/-
40-
value: --enable-module
41-
- op: add
42-
path: /spec/template/spec/containers/0/args/-
43-
value: --enable-namespace
44-
- op: add
45-
path: /spec/template/spec/containers/0/args/-
46-
value: --enable-preflightvalidation
47-
4821
replacements:
49-
# The following patches adds a directive for certmanager to inject CA into the CRD
22+
# Replacements below adjust the value of the cert-manager.io/inject-ca-from annotation in CRDs and webhook objects.
5023
- source:
5124
kind: Certificate
5225
fieldPath: metadata.namespace
5326
targets:
54-
- select:
55-
kind: CustomResourceDefinition
56-
name: modules.kmm.sigs.x-k8s.io
57-
fieldPaths:
58-
- metadata.annotations.[cert-manager.io/inject-ca-from]
59-
options:
60-
delimiter: /
6127
- select:
6228
kind: CustomResourceDefinition
6329
name: preflightvalidations.kmm.sigs.x-k8s.io
6430
fieldPaths:
6531
- metadata.annotations.[cert-manager.io/inject-ca-from]
6632
options:
33+
create: true
6734
delimiter: /
6835
- select:
6936
kind: ValidatingWebhookConfiguration
7037
fieldPaths:
7138
- metadata.annotations.[cert-manager.io/inject-ca-from]
7239
options:
40+
create: true
7341
delimiter: /
7442
- source:
7543
kind: Certificate
7644
fieldPath: metadata.name
7745
targets:
78-
- select:
79-
kind: CustomResourceDefinition
80-
name: modules.kmm.sigs.x-k8s.io
81-
fieldPaths:
82-
- metadata.annotations.[cert-manager.io/inject-ca-from]
83-
options:
84-
delimiter: /
85-
index: 1
8646
- select:
8747
kind: CustomResourceDefinition
8848
name: preflightvalidations.kmm.sigs.x-k8s.io
8949
fieldPaths:
9050
- metadata.annotations.[cert-manager.io/inject-ca-from]
9151
options:
52+
create: true
9253
delimiter: /
9354
index: 1
9455
- select:
9556
kind: ValidatingWebhookConfiguration
9657
fieldPaths:
9758
- metadata.annotations.[cert-manager.io/inject-ca-from]
9859
options:
60+
create: true
9961
delimiter: /
10062
index: 1
101-
# Patch dnsNames in webhook Certificate
63+
# Replacements below adjust the DNS names of the webhook certificate based on the service name.
10264
- source:
10365
kind: Service
104-
name: webhook-server-service
66+
name: webhook-service
10567
fieldPath: metadata.name
10668
targets:
10769
- select:
@@ -112,7 +74,7 @@ replacements:
11274
delimiter: .
11375
- source:
11476
kind: Service
115-
name: webhook-server-service
77+
name: webhook-service
11678
fieldPath: metadata.namespace
11779
targets:
11880
- select:

config/default/webhookcainjection_patch.yaml

-15
This file was deleted.

config/deploy-hub/kustomization.yaml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
4+
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in crd/kustomization.yaml
5+
# [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER'. 'WEBHOOK' components are required.
6+
resources:
7+
- ../crd-hub
8+
- ../rbac-hub
9+
- ../manager-hub
10+
- ../webhook-hub
11+
# [PROMETHEUS] To enable prometheus monitor, uncomment all sections with 'PROMETHEUS'.
12+
#- ../prometheus
13+
- ../webhook-server
14+
15+
patches:
16+
- target:
17+
kind: Deployment
18+
name: webhook-server
19+
patch: |-
20+
- op: add
21+
path: /spec/template/spec/containers/0/args/-
22+
value: --enable-managedclustermodule

0 commit comments

Comments
 (0)