Skip to content

Commit a9307a0

Browse files
author
Per Goncalves da Silva
committed
Add catalogd webhook exp/standard split
Signed-off-by: Per Goncalves da Silva <[email protected]>
1 parent 4c3456a commit a9307a0

File tree

11 files changed

+82
-10
lines changed

11 files changed

+82
-10
lines changed

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ tidy:
142142

143143
.PHONY: manifests
144144
KUSTOMIZE_CATD_RBAC_DIR := config/base/catalogd/rbac
145-
KUSTOMIZE_CATD_WEBHOOKS_DIR := config/base/catalogd/manager/webhook
145+
KUSTOMIZE_CATD_WEBHOOKS_DIR := config/base/catalogd/webhook
146146
KUSTOMIZE_OPCON_RBAC_DIR := config/base/operator-controller/rbac
147147
# Due to https://github.com/kubernetes-sigs/controller-tools/issues/837 we can't specify individual files
148148
# So we have to generate them together and then move them into place
@@ -155,9 +155,10 @@ manifests: $(CONTROLLER_GEN) $(KUSTOMIZE) #EXHELP Generate WebhookConfiguration,
155155
$(CONTROLLER_GEN) --load-build-tags=$(GO_BUILD_TAGS) rbac:roleName=manager-role paths="./internal/operator-controller/..." output:rbac:artifacts:config=$(KUSTOMIZE_OPCON_RBAC_DIR)/experimental
156156
# Generate the remaining catalogd standard manifests
157157
$(CONTROLLER_GEN) --load-build-tags=$(GO_BUILD_TAGS),standard rbac:roleName=manager-role paths="./internal/catalogd/..." output:rbac:artifacts:config=$(KUSTOMIZE_CATD_RBAC_DIR)/standard
158-
$(CONTROLLER_GEN) --load-build-tags=$(GO_BUILD_TAGS) webhook paths="./internal/catalogd/..." output:webhook:artifacts:config=$(KUSTOMIZE_CATD_WEBHOOKS_DIR)
158+
$(CONTROLLER_GEN) --load-build-tags=$(GO_BUILD_TAGS),standard webhook paths="./internal/catalogd/..." output:webhook:artifacts:config=$(KUSTOMIZE_CATD_WEBHOOKS_DIR)/standard
159159
# Generate the remaining catalogd experimental manifests
160160
$(CONTROLLER_GEN) --load-build-tags=$(GO_BUILD_TAGS) rbac:roleName=manager-role paths="./internal/catalogd/..." output:rbac:artifacts:config=$(KUSTOMIZE_CATD_RBAC_DIR)/experimental
161+
$(CONTROLLER_GEN) --load-build-tags=$(GO_BUILD_TAGS) webhook paths="./internal/catalogd/..." output:webhook:artifacts:config=$(KUSTOMIZE_CATD_WEBHOOKS_DIR)/experimental
161162
# Generate manifests stored in source-control
162163
mkdir -p $(MANIFEST_HOME)
163164
$(KUSTOMIZE) build $(KUSTOMIZE_STANDARD_OVERLAY) > $(STANDARD_MANIFEST)

config/base/catalogd/manager/kustomization.yaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,9 @@ resources:
22
- manager.yaml
33
- service.yaml
44
- network_policy.yaml
5-
- webhook/manifests.yaml
65
apiVersion: kustomize.config.k8s.io/v1beta1
76
kind: Kustomization
87
images:
98
- name: controller
109
newName: quay.io/operator-framework/catalogd
1110
newTag: devel
12-
patches:
13-
- path: webhook/patch.yaml
14-
target:
15-
group: admissionregistration.k8s.io
16-
kind: MutatingWebhookConfiguration
17-
name: mutating-webhook-configuration
18-
version: v1
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
resources:
2+
- manifests.yaml
3+
apiVersion: kustomize.config.k8s.io/v1beta1
4+
kind: Kustomization
5+
namespace: olmv1-system
6+
namePrefix: catalogd-
7+
patches:
8+
- path: patch.yaml
9+
target:
10+
group: admissionregistration.k8s.io
11+
kind: MutatingWebhookConfiguration
12+
name: mutating-webhook-configuration
13+
version: v1
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# This kustomization picks the standard webhook by default
2+
# If the experimental webhook is desired, select that directory explicitly
3+
resources:
4+
- standard
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
resources:
2+
- manifests.yaml
3+
apiVersion: kustomize.config.k8s.io/v1beta1
4+
kind: Kustomization
5+
namespace: olmv1-system
6+
namePrefix: catalogd-
7+
patches:
8+
- path: patch.yaml
9+
target:
10+
group: admissionregistration.k8s.io
11+
kind: MutatingWebhookConfiguration
12+
name: mutating-webhook-configuration
13+
version: v1
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
apiVersion: admissionregistration.k8s.io/v1
3+
kind: MutatingWebhookConfiguration
4+
metadata:
5+
name: mutating-webhook-configuration
6+
webhooks:
7+
- admissionReviewVersions:
8+
- v1
9+
clientConfig:
10+
service:
11+
name: webhook-service
12+
namespace: system
13+
path: /mutate-olm-operatorframework-io-v1-clustercatalog
14+
failurePolicy: Fail
15+
name: inject-metadata-name.olm.operatorframework.io
16+
rules:
17+
- apiGroups:
18+
- olm.operatorframework.io
19+
apiVersions:
20+
- v1
21+
operations:
22+
- CREATE
23+
- UPDATE
24+
resources:
25+
- clustercatalogs
26+
sideEffects: None
27+
timeoutSeconds: 10
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# None of these values can be set via the kubebuilder directive, hence this patch
2+
- op: replace
3+
path: /webhooks/0/clientConfig/service/namespace
4+
value: olmv1-system
5+
- op: replace
6+
path: /webhooks/0/clientConfig/service/name
7+
value: catalogd-service
8+
- op: add
9+
path: /webhooks/0/clientConfig/service/port
10+
value: 9443
11+
# Make sure there's a name defined, otherwise, we can't create a label. This could happen when generateName is set
12+
# Then, if any of the conditions are true, create the label:
13+
# 1. No labels exist
14+
# 2. The olm.operatorframework.io/metadata.name label doesn't exist
15+
# 3. The olm.operatorframework.io/metadata.name label doesn't match the name
16+
- op: add
17+
path: /webhooks/0/matchConditions
18+
value:
19+
- name: MissingOrIncorrectMetadataNameLabel
20+
expression: "'name' in object.metadata && (!has(object.metadata.labels) || !('olm.operatorframework.io/metadata.name' in object.metadata.labels) || object.metadata.labels['olm.operatorframework.io/metadata.name'] != object.metadata.name)"

config/components/base/experimental/kustomization.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ kind: Component
44
resources:
55
- ../../../base/catalogd/crd/experimental
66
- ../../../base/catalogd/rbac/experimental
7+
- ../../../base/catalogd/webhook/experimental
78
- ../../../base/operator-controller/crd/experimental
89
- ../../../base/operator-controller/rbac/experimental
910
# Pull in the component(s) common to standard and experimental

0 commit comments

Comments
 (0)