Skip to content

Commit 3fa247f

Browse files
VanillaSpoonastefanutti
authored andcommitted
add: mutating webhook
1 parent 8b3b27c commit 3fa247f

File tree

13 files changed

+279
-3
lines changed

13 files changed

+279
-3
lines changed

PROJECT

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,9 @@ resources:
1515
domain: codeflare.dev
1616
group: ray
1717
kind: RayCluster
18+
path: github.com/project-codeflare/codeflare-operator/pkg/controllers
1819
version: v1
20+
webhooks:
21+
defaulting: true
22+
webhookVersion: v1
1923
version: "3"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# The following manifests contain a self-signed issuer CR and a certificate CR.
2+
# More document can be found at https://docs.cert-manager.io
3+
# WARNING: Targets CertManager v1.0. Check https://cert-manager.io/docs/installation/upgrading/ for breaking changes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
resources:
2+
- certificate.yaml
3+
4+
configurations:
5+
- kustomizeconfig.yaml
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# This configuration is for teaching kustomize how to update name ref and var substitution
2+
nameReference:
3+
- kind: Issuer
4+
group: cert-manager.io
5+
fieldSpecs:
6+
- kind: Certificate
7+
group: cert-manager.io
8+
path: spec/issuerRef/name
9+
10+
varReference:
11+
- kind: Certificate
12+
group: cert-manager.io
13+
path: spec/commonName
14+
- kind: Certificate
15+
group: cert-manager.io
16+
path: spec/dnsNames

config/default/kustomization.yaml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,15 @@ commonLabels:
1414
app.kubernetes.io/part-of: codeflare
1515

1616
bases:
17-
- ../rbac
18-
- ../manager
17+
- ../rbac
18+
- ../manager
19+
- ../webhook
1920
# [PROMETHEUS] To enable prometheus monitor, uncomment all sections with 'PROMETHEUS'.
2021
# - ../prometheus
2122

2223
resources:
23-
- metrics_service.yaml
24+
- metrics_service.yaml
25+
26+
patches:
27+
- path: manager_webhook_patch.yaml
28+
- path: webhookcainjection_patch.yaml
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: manager
5+
namespace: system
6+
spec:
7+
template:
8+
spec:
9+
containers:
10+
- name: manager
11+
ports:
12+
- containerPort: 9443
13+
name: webhook-server
14+
protocol: TCP
15+
volumeMounts:
16+
- mountPath: /tmp/k8s-webhook-server/serving-certs
17+
name: cert
18+
readOnly: true
19+
volumes:
20+
- name: cert
21+
secret:
22+
defaultMode: 420
23+
secretName: codeflare-operator-raycluster-webhook-cert
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# This patch add annotation to admission webhook config
2+
apiVersion: admissionregistration.k8s.io/v1
3+
kind: MutatingWebhookConfiguration
4+
metadata:
5+
labels:
6+
app.kubernetes.io/name: mutatingwebhookconfiguration
7+
app.kubernetes.io/instance: mutating-webhook-configuration
8+
app.kubernetes.io/component: webhook
9+
app.kubernetes.io/created-by: codeflare-operator
10+
app.kubernetes.io/part-of: codeflare-operator
11+
app.kubernetes.io/managed-by: kustomize
12+
name: mutating-webhook-configuration
13+
annotations:
14+
service.beta.openshift.io/inject-cabundle: "true"
15+
service.beta.openshift.io/serving-cert-secret-name: codeflare-operator-raycluster-webhook-cert

config/webhook/kustomization.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
resources:
2+
- manifests.yaml
3+
- service.yaml
4+
5+
configurations:
6+
- kustomizeconfig.yaml
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# the following config is for teaching kustomize where to look at when substituting vars.
2+
# It requires kustomize v2.1.0 or newer to work properly.
3+
nameReference:
4+
- kind: Service
5+
version: v1
6+
fieldSpecs:
7+
- kind: MutatingWebhookConfiguration
8+
group: admissionregistration.k8s.io
9+
path: webhooks/clientConfig/service/name
10+
- kind: ValidatingWebhookConfiguration
11+
group: admissionregistration.k8s.io
12+
path: webhooks/clientConfig/service/name
13+
14+
namespace:
15+
- kind: MutatingWebhookConfiguration
16+
group: admissionregistration.k8s.io
17+
path: webhooks/clientConfig/service/namespace
18+
create: true
19+
- kind: ValidatingWebhookConfiguration
20+
group: admissionregistration.k8s.io
21+
path: webhooks/clientConfig/service/namespace
22+
create: true
23+
24+
varReference:
25+
- path: metadata/annotations

config/webhook/manifests.yaml

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+
creationTimestamp: null
6+
name: mutating-webhook-configuration
7+
webhooks:
8+
- admissionReviewVersions:
9+
- v1
10+
clientConfig:
11+
service:
12+
name: webhook-service
13+
namespace: system
14+
path: /mutate-ray-io-v1-raycluster
15+
failurePolicy: Fail
16+
name: mraycluster.kb.io
17+
rules:
18+
- apiGroups:
19+
- ray.io
20+
apiVersions:
21+
- v1
22+
operations:
23+
- CREATE
24+
- UPDATE
25+
resources:
26+
- rayclusters
27+
sideEffects: None

0 commit comments

Comments
 (0)