Skip to content

Commit 54a9488

Browse files
authored
Add example YAML for manually enabling Ray k8s auth (#4582)
Signed-off-by: Andrew Sy Kim <andrewsy@google.com>
1 parent fe40455 commit 54a9488

1 file changed

Lines changed: 134 additions & 0 deletions

File tree

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
apiVersion: ray.io/v1
2+
kind: RayCluster
3+
metadata:
4+
name: ray-cluster-with-k8s-auth
5+
spec:
6+
rayVersion: '2.55.0'
7+
headGroupSpec:
8+
rayStartParams: {}
9+
template:
10+
spec:
11+
serviceAccountName: raylet
12+
containers:
13+
- name: ray-head
14+
imagePullPolicy: Always
15+
# TODO: update to rayproject/ray:2.55.0 once released
16+
image: rayproject/ray:nightly
17+
env:
18+
- name: RAY_AUTH_MODE
19+
value: "token"
20+
- name: RAY_ENABLE_K8S_TOKEN_AUTH
21+
value: "true"
22+
resources:
23+
limits:
24+
cpu: "4"
25+
memory: "8Gi"
26+
requests:
27+
cpu: "4"
28+
memory: "8Gi"
29+
ports:
30+
- containerPort: 6379
31+
name: gcs-server
32+
- containerPort: 8265
33+
name: dashboard
34+
- containerPort: 10001
35+
name: client
36+
volumeMounts:
37+
- mountPath: /var/run/secrets/ray.io/serviceaccount
38+
name: ray-token
39+
volumes:
40+
- name: ray-token
41+
projected:
42+
sources:
43+
- serviceAccountToken:
44+
path: token
45+
workerGroupSpecs:
46+
- replicas: 1
47+
minReplicas: 1
48+
maxReplicas: 5
49+
groupName: workergroup
50+
rayStartParams: {}
51+
template:
52+
spec:
53+
serviceAccountName: raylet
54+
containers:
55+
- name: ray-worker
56+
imagePullPolicy: Always
57+
# TODO: update to rayproject/ray:2.55.0 once released
58+
image: rayproject/ray:nightly
59+
env:
60+
- name: RAY_AUTH_MODE
61+
value: "token"
62+
- name: RAY_ENABLE_K8S_TOKEN_AUTH
63+
value: "true"
64+
resources:
65+
limits:
66+
cpu: "4"
67+
memory: "8Gi"
68+
requests:
69+
cpu: "4"
70+
memory: "8Gi"
71+
volumeMounts:
72+
- mountPath: /var/run/secrets/ray.io/serviceaccount
73+
name: ray-token
74+
volumes:
75+
- name: ray-token
76+
projected:
77+
sources:
78+
- serviceAccountToken:
79+
path: token
80+
---
81+
apiVersion: v1
82+
kind: ServiceAccount
83+
metadata:
84+
name: raylet
85+
---
86+
apiVersion: rbac.authorization.k8s.io/v1
87+
kind: ClusterRole
88+
metadata:
89+
name: ray-authenticator
90+
rules:
91+
- apiGroups: ["authentication.k8s.io"]
92+
resources:
93+
- 'tokenreviews'
94+
verbs: ["create"]
95+
- apiGroups: ["authorization.k8s.io"]
96+
resources:
97+
- 'subjectaccessreviews'
98+
verbs: ["create"]
99+
---
100+
apiVersion: rbac.authorization.k8s.io/v1
101+
kind: ClusterRole
102+
metadata:
103+
name: ray-writer
104+
rules:
105+
- apiGroups: ["ray.io"]
106+
resources:
107+
- 'rayclusters'
108+
verbs: ["ray:write"]
109+
---
110+
apiVersion: rbac.authorization.k8s.io/v1
111+
kind: ClusterRoleBinding
112+
metadata:
113+
name: ray-authenticator
114+
roleRef:
115+
apiGroup: rbac.authorization.k8s.io
116+
kind: ClusterRole
117+
name: ray-authenticator
118+
subjects:
119+
- kind: ServiceAccount
120+
name: raylet
121+
namespace: default
122+
---
123+
apiVersion: rbac.authorization.k8s.io/v1
124+
kind: RoleBinding
125+
metadata:
126+
name: raylet
127+
roleRef:
128+
apiGroup: rbac.authorization.k8s.io
129+
kind: ClusterRole
130+
name: ray-writer
131+
subjects:
132+
- kind: ServiceAccount
133+
name: raylet
134+
namespace: default

0 commit comments

Comments
 (0)