Skip to content

Commit 5cb51fc

Browse files
committed
add: webhook configuration along with CO kustomize and address feedback
1 parent 45bc0a0 commit 5cb51fc

9 files changed

+142
-0
lines changed

config/default/kustomization.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ commonLabels:
1616
bases:
1717
- ../rbac
1818
- ../manager
19+
- ../raycluster_webhook
1920
# [PROMETHEUS] To enable prometheus monitor, uncomment all sections with 'PROMETHEUS'.
2021
# - ../prometheus
2122

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRole
3+
metadata:
4+
name: raycluster-mutating-webhook
5+
rules:
6+
- apiGroups: [""]
7+
resources: ["pods"]
8+
verbs: ["get", "watch", "list"]
9+
- apiGroups: ["ray.io"]
10+
resources: ["rayclusters"]
11+
verbs: ["get", "watch", "list", "update", "patch"]
12+
- apiGroups: [""]
13+
resources: ["secrets"]
14+
verbs: ["get", "watch", "list"]
15+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRoleBinding
3+
metadata:
4+
name: raycluster-mutating-webhook
5+
subjects:
6+
- kind: ServiceAccount
7+
name: raycluster-mutating-webhook
8+
namespace: system
9+
roleRef:
10+
kind: ClusterRole
11+
name: raycluster-mutating-webhook
12+
apiGroup: rbac.authorization.k8s.io
+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: raycluster-mutating-webhook
5+
namespace: system
6+
labels:
7+
app: raycluster-mutating-webhook
8+
spec:
9+
replicas: 1
10+
selector:
11+
matchLabels:
12+
app: raycluster-mutating-webhook
13+
template:
14+
metadata:
15+
labels:
16+
app: raycluster-mutating-webhook
17+
spec:
18+
nodeSelector:
19+
kubernetes.io/os: linux
20+
serviceAccountName: raycluster-mutating-webhook
21+
securityContext:
22+
runAsNonRoot: true
23+
runAsUser: 1234
24+
containers:
25+
- name: server
26+
image: quay.io/rh_ee_egallina/altwebhook:v89
27+
imagePullPolicy: Always
28+
ports:
29+
- containerPort: 8443
30+
name: tls
31+
- containerPort: 80
32+
name: metrics
33+
volumeMounts:
34+
- name: webhook-tls-certs
35+
mountPath: /etc/webhook/certs
36+
readOnly: true
37+
volumes:
38+
- name: webhook-tls-certs
39+
secret:
40+
secretName: raycluster-webhook-cert
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
resources:
2+
# All RBAC will be applied under this service account in
3+
# the deployment namespace. You may comment out this resource
4+
# if your manager will use a service account that exists at
5+
# runtime. Be sure to update RoleBinding and ClusterRoleBinding
6+
# subjects if changing service account names.
7+
- deployment.yaml
8+
- service_account.yaml
9+
- cluster_role.yaml
10+
- cluster_role_binding.yaml
11+
- service.yaml
12+
- mutating_webhook_configuration.yaml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
apiVersion: admissionregistration.k8s.io/v1
2+
kind: MutatingWebhookConfiguration
3+
metadata:
4+
name: raycluster-mutating-webhook
5+
annotations:
6+
service.beta.openshift.io/inject-cabundle: "true"
7+
webhooks:
8+
- name: raycluster-mutating-webhook.codeflare.com
9+
admissionReviewVersions: ["v1beta1"]
10+
sideEffects: None
11+
timeoutSeconds: 30
12+
failurePolicy: Ignore
13+
clientConfig:
14+
caBundle: Cg==
15+
service:
16+
name: raycluster-mutating-webhook
17+
namespace: system
18+
path: "/mutate"
19+
rules:
20+
- operations: ["CREATE", "UPDATE"]
21+
apiGroups: ["ray.io"]
22+
apiVersions: ["v1"]
23+
resources: ["rayclusters"]
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: raycluster-mutating-webhook
5+
namespace: system
6+
annotations:
7+
service.beta.openshift.io/serving-cert-secret-name: raycluster-webhook-cert
8+
spec:
9+
selector:
10+
app: raycluster-mutating-webhook
11+
ports:
12+
- port: 443
13+
targetPort: tls
14+
name: application
15+
- port: 80
16+
targetPort: metrics
17+
name: metrics
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apiVersion: v1
2+
kind: ServiceAccount
3+
metadata:
4+
name: raycluster-mutating-webhook
5+
namespace: system
6+

raycluster_webhook/src/patches.go

+16
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,21 @@ func createPatch(rayCluster *rayv1api.RayCluster) ([]patchOperation, error) {
7979
Value: newOAuthSidecar,
8080
})
8181

82+
tlsSecretVolume := corev1.Volume{
83+
Name: "proxy-tls-secret",
84+
VolumeSource: corev1.VolumeSource{
85+
Secret: &corev1.SecretVolumeSource{
86+
SecretName: rayclusterName + "-proxy-tls-secret",
87+
},
88+
},
89+
}
90+
91+
// Patch to add new volume
92+
patches = append(patches, patchOperation{
93+
Op: "add",
94+
Path: "/spec/headGroupSpec/template/spec/volumes/-",
95+
Value: tlsSecretVolume,
96+
})
97+
8298
return patches, nil
8399
}

0 commit comments

Comments
 (0)