@@ -11,37 +11,15 @@ run_name="gpu_class_test"
1111image_name=" csw-dev-f25"
1212
1313create_wb () {
14- random_id=$( openssl rand -hex 3)
15-
1614 # set namespace
1715 namespace=$1
1816
19- username=$( oc -n " $ns " get rolebinding edit -o json \
20- | jq -r '
21- (.subjects // [])
22- | map(.name)
23- | map(select(. != "jappavoo-40bu-2edu"))
24- | map(select(. != "sdanni-40redhat-2com"))
25- | map(select(. != "istaplet"))
26- | .[]
27- ' )
28-
29- user=$( oc -n " $ns " get rolebinding edit -o json \
30- | jq -r '
31- (.subjects // [])
32- | map(.name
33- | if test("@.*\\..*$")
34- then sub("@"; "-40") | gsub("\\.";"-2")
35- else .
36- end)
37- | map(select(. != "jappavoo-40bu-2edu"))
38- | map(select(. != "sdanni-40redhat-2com"))
39- | map(select(. != "istaplet"))
40- | .[]
41- ' )
17+ 18+
19+ user=" jappavoo-40bu-2edu"
4220
4321 # give notebook within namespace a name
44- notebook_name=cs599- ${user} -wb
22+ notebook_name=" csw-dev "
4523
4624 params=(
4725 -p NOTEBOOK_NAME=" $notebook_name "
@@ -79,22 +57,35 @@ apply_rolebinding() {
7957 -p SERVICE_ACCOUNT_NB=" $notebook_name "
8058 )
8159
82- oc process -f rb .yaml --local " ${rb_params[@]} " | " ${create_resource_command[@]} " --as system:admin
60+ oc process -f rbac_template .yaml --local " ${rb_params[@]} " | " ${create_resource_command[@]} " --as system:admin
8361}
8462
85- apply_clusterq () {
63+ create_clusterrole_bindings () {
64+
65+ oc apply -f clusterrole.yaml --as system:admin
66+ # oc create will fail if resource exists (safer)
67+ oc create -f clusterrolebinding.yaml --as system:admin
68+ }
69+
70+ add_sa_to_clusterrolebinding () {
71+ namespace=$1
72+ notebook_name=$2
8673
87- oc apply -f cluster_queue_role.yaml --as system:admin
74+ oc adm policy add-cluster-role-to-user pod-reader --rolebinding-name=" csw-pod-reader" system:serviceaccount:$namespace :$notebook_name --as system:admin
75+ oc adm policy add-cluster-role-to-user node-reader --rolebinding-name=" csw-node-reader" system:serviceaccount:$namespace :$notebook_name --as system:admin
76+ oc adm policy add-cluster-role-to-user kueue-clusterqueue-reader --rolebinding-name=" csw-kueue-clusterqueue-reader" system:serviceaccount:$namespace :$notebook_name --as system:admin
8877}
8978
90- apply_clusterq
79+ create_clusterrole_bindings
9180
92- oc get ns | grep " ^${CLASS_NAME} -" | awk ' {print $1}' | while read ns; do
93- oc project " $ns "
81+ # oc get ns | grep "^${CLASS_NAME}-" | awk '{print $1}' | while read ns; do
82+ ns=" bu-cs599-pmpp-cuda-71cd48"
83+ oc project " $ns "
9484
95- # create a workbench and save the name of the notebook to apply rolebindings
96- nb_name=" $( create_wb " $ns " ) "
97- apply_rolebinding " $ns " " $nb_name "
98- apply_localqueue " $ns "
85+ # create a workbench and save the name of the notebook to apply rolebindings
86+ nb_name=" $( create_wb " $ns " ) "
87+ apply_rolebinding " $ns " " $nb_name "
88+ apply_localqueue " $ns "
89+ add_sa_to_clusterrolebinding " $ns " " $nb_name "
9990
100- done
91+ # done
0 commit comments