|
| 1 | +--- |
| 2 | +# RBAC permissions for test user to run e2e tests |
| 3 | +# Apply this as cluster-admin before running tests: |
| 4 | +# oc apply -f images/tests/rbac-test-user-permissions.yaml |
| 5 | +# OR |
| 6 | +# kubectl apply -f images/tests/rbac-test-user-permissions.yaml |
| 7 | +# |
| 8 | +# The username "TEST_USER_USERNAME_PLACEHOLDER" will be replaced at runtime with the actual test username |
| 9 | + |
| 10 | +# For OpenShift: Grant self-provisioner role (allows namespace creation) |
| 11 | +# This is the recommended approach for OpenShift |
| 12 | +apiVersion: rbac.authorization.k8s.io/v1 |
| 13 | +kind: ClusterRoleBinding |
| 14 | +metadata: |
| 15 | + name: test-user-self-provisioner |
| 16 | + # For OpenShift, you can also use: oc adm policy add-cluster-role-to-user self-provisioner TEST_USER_USERNAME_PLACEHOLDER |
| 17 | +subjects: |
| 18 | +- kind: User |
| 19 | + name: TEST_USER_USERNAME_PLACEHOLDER |
| 20 | + apiGroup: rbac.authorization.k8s.io |
| 21 | +roleRef: |
| 22 | + kind: ClusterRole |
| 23 | + name: self-provisioner |
| 24 | + apiGroup: rbac.authorization.k8s.io |
| 25 | +--- |
| 26 | +# Alternative: Grant admin role (more permissive, use if self-provisioner doesn't work) |
| 27 | +# For OpenShift, you can also use: oc adm policy add-cluster-role-to-user admin TEST_USER_USERNAME_PLACEHOLDER |
| 28 | +apiVersion: rbac.authorization.k8s.io/v1 |
| 29 | +kind: ClusterRoleBinding |
| 30 | +metadata: |
| 31 | + name: test-user-admin |
| 32 | +subjects: |
| 33 | +- kind: User |
| 34 | + name: TEST_USER_USERNAME_PLACEHOLDER |
| 35 | + apiGroup: rbac.authorization.k8s.io |
| 36 | +roleRef: |
| 37 | + kind: ClusterRole |
| 38 | + name: admin |
| 39 | + apiGroup: rbac.authorization.k8s.io |
| 40 | +--- |
| 41 | +# For Kubernetes: Grant cluster-admin role (allows all operations including namespace creation) |
| 42 | +# This is more permissive but ensures all test operations work |
| 43 | +apiVersion: rbac.authorization.k8s.io/v1 |
| 44 | +kind: ClusterRoleBinding |
| 45 | +metadata: |
| 46 | + name: test-user-cluster-admin |
| 47 | +subjects: |
| 48 | +- kind: User |
| 49 | + name: TEST_USER_USERNAME_PLACEHOLDER |
| 50 | + apiGroup: rbac.authorization.k8s.io |
| 51 | +roleRef: |
| 52 | + kind: ClusterRole |
| 53 | + name: cluster-admin |
| 54 | + apiGroup: rbac.authorization.k8s.io |
| 55 | +--- |
| 56 | +# Additional permissions for Kueue resources (if needed) |
| 57 | +# This allows the user to create/manage Kueue CustomResources |
| 58 | +apiVersion: rbac.authorization.k8s.io/v1 |
| 59 | +kind: ClusterRole |
| 60 | +metadata: |
| 61 | + name: test-user-kueue-admin |
| 62 | +rules: |
| 63 | +- apiGroups: |
| 64 | + - kueue.x-k8s.io |
| 65 | + resources: |
| 66 | + - clusterqueues |
| 67 | + - resourceflavors |
| 68 | + - localqueues |
| 69 | + - workloads |
| 70 | + verbs: |
| 71 | + - get |
| 72 | + - list |
| 73 | + - watch |
| 74 | + - create |
| 75 | + - update |
| 76 | + - patch |
| 77 | + - delete |
| 78 | +--- |
| 79 | +apiVersion: rbac.authorization.k8s.io/v1 |
| 80 | +kind: ClusterRoleBinding |
| 81 | +metadata: |
| 82 | + name: test-user-kueue-admin |
| 83 | +subjects: |
| 84 | +- kind: User |
| 85 | + name: TEST_USER_USERNAME_PLACEHOLDER |
| 86 | + apiGroup: rbac.authorization.k8s.io |
| 87 | +roleRef: |
| 88 | + kind: ClusterRole |
| 89 | + name: test-user-kueue-admin |
| 90 | + apiGroup: rbac.authorization.k8s.io |
| 91 | +--- |
| 92 | +# Permissions for RayCluster and RayJob CustomResources |
| 93 | +apiVersion: rbac.authorization.k8s.io/v1 |
| 94 | +kind: ClusterRole |
| 95 | +metadata: |
| 96 | + name: test-user-ray-admin |
| 97 | +rules: |
| 98 | +- apiGroups: |
| 99 | + - ray.io |
| 100 | + resources: |
| 101 | + - rayclusters |
| 102 | + - rayjobs |
| 103 | + verbs: |
| 104 | + - get |
| 105 | + - list |
| 106 | + - watch |
| 107 | + - create |
| 108 | + - update |
| 109 | + - patch |
| 110 | + - delete |
| 111 | +--- |
| 112 | +apiVersion: rbac.authorization.k8s.io/v1 |
| 113 | +kind: ClusterRoleBinding |
| 114 | +metadata: |
| 115 | + name: test-user-ray-admin |
| 116 | +subjects: |
| 117 | +- kind: User |
| 118 | + name: TEST_USER_USERNAME_PLACEHOLDER |
| 119 | + apiGroup: rbac.authorization.k8s.io |
| 120 | +roleRef: |
| 121 | + kind: ClusterRole |
| 122 | + name: test-user-ray-admin |
| 123 | + apiGroup: rbac.authorization.k8s.io |
| 124 | +--- |
| 125 | +# Comprehensive RBAC role for Kueue batch operations |
| 126 | +# This role provides permissions for namespaces, Kueue, Ray, and core Kubernetes resources |
| 127 | +apiVersion: rbac.authorization.k8s.io/v1 |
| 128 | +kind: ClusterRole |
| 129 | +metadata: |
| 130 | + name: kueue-batch-user-role |
| 131 | +rules: |
| 132 | +- apiGroups: [""] |
| 133 | + resources: ["namespaces"] |
| 134 | + verbs: ["create", "get", "list", "watch"] |
| 135 | +- apiGroups: ["kueue.x-k8s.io"] |
| 136 | + resources: ["clusterqueues", "resourceflavors", "localqueues"] |
| 137 | + verbs: ["create", "get", "list", "watch", "update", "patch", "delete"] |
| 138 | +- apiGroups: ["ray.io"] |
| 139 | + resources: ["rayclusters", "rayjobs"] |
| 140 | + verbs: ["create", "get", "list", "watch", "update", "patch", "delete"] |
| 141 | +- apiGroups: ["apps"] |
| 142 | + resources: ["deployments"] |
| 143 | + verbs: ["create", "get", "list", "watch", "update", "patch", "delete"] |
| 144 | +- apiGroups: [""] |
| 145 | + resources: ["pods", "services", "configmaps", "secrets"] |
| 146 | + verbs: ["create", "get", "list", "watch", "update", "patch", "delete"] |
| 147 | +--- |
| 148 | +# ClusterRoleBinding for authenticated users (group-based) |
| 149 | +apiVersion: rbac.authorization.k8s.io/v1 |
| 150 | +kind: ClusterRoleBinding |
| 151 | +metadata: |
| 152 | + name: kueue-batch-user-rolebinding |
| 153 | +subjects: |
| 154 | + - kind: Group |
| 155 | + apiGroup: rbac.authorization.k8s.io |
| 156 | + name: 'system:authenticated' |
| 157 | +roleRef: |
| 158 | + apiGroup: rbac.authorization.k8s.io |
| 159 | + kind: ClusterRole |
| 160 | + name: kueue-batch-user-role |
| 161 | +--- |
| 162 | +# ClusterRoleBinding for specific test user |
| 163 | +apiVersion: rbac.authorization.k8s.io/v1 |
| 164 | +kind: ClusterRoleBinding |
| 165 | +metadata: |
| 166 | + name: kueue-batch-user-specific-rolebinding |
| 167 | +subjects: |
| 168 | + - kind: User |
| 169 | + apiGroup: rbac.authorization.k8s.io |
| 170 | + name: 'TEST_USER_USERNAME_PLACEHOLDER' |
| 171 | +roleRef: |
| 172 | + apiGroup: rbac.authorization.k8s.io |
| 173 | + kind: ClusterRole |
| 174 | + name: kueue-batch-user-role |
0 commit comments