Skip to content

Commit

Permalink
Restrict the mutating webhook to cass-operator managed pods (#1173)
Browse files Browse the repository at this point in the history
  • Loading branch information
adejanovski authored Jan 16, 2024
1 parent 4f244a9 commit 413f04f
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 13 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG/CHANGELOG-1.11.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ When cutting a new release, update the `unreleased` heading to the tag being gen

## unreleased

* [BUGFIX] [#1172](https://github.com/k8ssandra/k8ssandra-operator/issues/1172) Restrict the mutating webhook to cass-operator managed pods

## v1.11.0 - 2023-12-20

* [CHANGE] Upgrade to Medusa v0.17.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@ webhooks:
failurePolicy: Fail
name: mpod.kb.io
objectSelector:
matchExpressions:
- key: control-plane
operator: NotIn
values:
- k8ssandra-operator
matchLabels:
app.kubernetes.io/created-by: cass-operator
rules:
- apiGroups:
- ""
Expand Down
12 changes: 5 additions & 7 deletions config/webhook/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ patchesJson6902:
path: /webhooks/0/clientConfig/service/name
value: k8ssandra-operator-webhook-service
# adding the objectSelector prevents the bootstrapping problem
# where the mutation request for the operator pod would be
# sent before the operator pod is created
# The objectSelector will be added to the MutatingWebhookConfiguration
# to restrict the webhook to pods created by cass-operator.
# They're the only pods that should be mutated to inject secrets.
patchesJson6902:
- target:
group: admissionregistration.k8s.io
Expand All @@ -37,7 +37,5 @@ patchesJson6902:
- op: add
path: /webhooks/0/objectSelector
value:
matchExpressions:
- key: control-plane
operator: NotIn
values: ["k8ssandra-operator"]
matchLabels:
app.kubernetes.io/created-by: cass-operator
31 changes: 30 additions & 1 deletion test/kuttl/test-cassandra-versions/01-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,33 @@ status:
- status: "True"
type: Available
- status: "True"
type: Progressing
type: Progressing
---
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
name: k8ssandra-operator-mutating-webhook-configuration
webhooks:
- name: mpod.kb.io
rules:
- operations:
- CREATE
- UPDATE
apiGroups:
- ''
apiVersions:
- v1
resources:
- pods
scope: '*'
failurePolicy: Fail
matchPolicy: Equivalent
namespaceSelector: {}
objectSelector:
matchLabels:
app.kubernetes.io/created-by: cass-operator
sideEffects: None
timeoutSeconds: 10
admissionReviewVersions:
- v1
reinvocationPolicy: Never

0 comments on commit 413f04f

Please sign in to comment.