Skip to content

Commit 78b586c

Browse files
yxd-ymarttor
authored andcommitted
Add samples for webhook configuration.
1 parent 1380157 commit 78b586c

File tree

3 files changed

+59
-2
lines changed

3 files changed

+59
-2
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
apiVersion: admissionregistration.k8s.io/v1
2+
kind: MutatingWebhookConfiguration
3+
metadata:
4+
name: {{ include "operator.fullname" . }}-mutating-webhook-configuration
5+
annotations:
6+
cert-manager.io/inject-ca-from: {{ .Release.Namespace }}/{{ include "operator.fullname" . }}-serving-cert
7+
labels:
8+
{{- include "operator.labels" . | nindent 4 }}
9+
webhooks:
10+
- admissionReviewVersions:
11+
- v1
12+
clientConfig:
13+
service:
14+
name: '{{ include "operator.fullname" . }}-webhook-service'
15+
namespace: '{{ .Release.Namespace }}'
16+
path: /mutate-ceph-example-com-v1-mycluster
17+
failurePolicy: Fail
18+
name: mmycluster.kb.io
19+
rules:
20+
- apiGroups:
21+
- test.example.com
22+
apiVersions:
23+
- v1
24+
operations:
25+
- CREATE
26+
- UPDATE
27+
resources:
28+
- myclusters
29+
sideEffects: None

examples/operator/templates/validating-webhook-configuration.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ kind: ValidatingWebhookConfiguration
33
metadata:
44
name: {{ include "operator.fullname" . }}-validating-webhook-configuration
55
annotations:
6-
cert-manager.io/inject-ca-from: {{ .Release.Namespace }}/{{ include "operator.fullname" . }}-my-operator-system/my-operator-serving-cert
6+
cert-manager.io/inject-ca-from: {{ .Release.Namespace }}/{{ include "operator.fullname" . }}-serving-cert
77
labels:
88
{{- include "operator.labels" . | nindent 4 }}
99
webhooks:

test_data/k8s-operator-kustomize.output

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ apiVersion: admissionregistration.k8s.io/v1
662662
kind: ValidatingWebhookConfiguration
663663
metadata:
664664
annotations:
665-
cert-manager.io/inject-ca-from: my-operator-system/my-operator-serving-cert
665+
cert-manager.io/inject-ca-from: my-operator-system/operator-serving-cert
666666
name: my-operator-validating-webhook-configuration
667667
webhooks:
668668
- admissionReviewVersions:
@@ -724,3 +724,31 @@ spec:
724724
requests:
725725
storage: 2Gi
726726
storageClassName: cust1-mypool-lim
727+
---
728+
apiVersion: admissionregistration.k8s.io/v1
729+
kind: MutatingWebhookConfiguration
730+
metadata:
731+
annotations:
732+
cert-manager.io/inject-ca-from: my-operator-system/operator-serving-cert
733+
name: my-operator-mutating-webhook-configuration
734+
webhooks:
735+
- admissionReviewVersions:
736+
- v1
737+
clientConfig:
738+
service:
739+
name: my-operator-webhook-service
740+
namespace: my-operator-system
741+
path: /mutate-ceph-example-com-v1-mycluster
742+
failurePolicy: Fail
743+
name: mmycluster.kb.io
744+
rules:
745+
- apiGroups:
746+
- test.example.com
747+
apiVersions:
748+
- v1
749+
operations:
750+
- CREATE
751+
- UPDATE
752+
resources:
753+
- myclusters
754+
sideEffects: None

0 commit comments

Comments
 (0)