File tree Expand file tree Collapse file tree 5 files changed +70
-0
lines changed
test/e2e/nemo-dependencies/jupyter Expand file tree Collapse file tree 5 files changed +70
-0
lines changed Original file line number Diff line number Diff line change 20
20
stdin : " {{ lookup('template', 'pvc.yaml.j2') }}"
21
21
executable : /bin/bash
22
22
23
+ - name : Get Kube API resources
24
+ command : kubectl api-resources --verbs=list --namespaced -o name
25
+ register : api_resources
26
+
27
+ - name : Check if the current cluster is OpenShift
28
+ set_fact :
29
+ is_openshift : " {{ 'routes.route.openshift.io' in api_resources.stdout_lines }}"
30
+
31
+ - name : OpenShift - Prepare RBAC to use anyuid SCC
32
+ ansible.builtin.template :
33
+ src : ocp-rbac.yaml.j2
34
+ dest : jupyter-ocp-rbac.yaml
35
+ when : is_openshift
36
+
37
+ - name : OpenShift - apply RBAC to use anyuid SCC
38
+ command : kubectl apply -f jupyter-ocp-rbac.yaml
39
+ when : is_openshift
40
+
41
+ - name : Create a service account
42
+ ansible.builtin.shell : |
43
+ kubectl apply -f -
44
+ args :
45
+ stdin : " {{ lookup('template', 'serviceaccount.yaml.j2') }}"
46
+ executable : /bin/bash
47
+
23
48
- name : Deploy Jupyter Notebook
24
49
ansible.builtin.shell : |
25
50
kubectl apply -f -
Original file line number Diff line number Diff line change 20
20
shell : kubectl delete configmap notebook-config -n {{ namespace }}
21
21
ignore_errors : true
22
22
23
+ - name : Delete Jupyter ServiceAccount
24
+ shell : kubectl delete sa jupyter -n {{ namespace }}
25
+ ignore_errors : true
26
+
Original file line number Diff line number Diff line change 12
12
metadata:
13
13
labels:
14
14
app: jupyter-notebook
15
+ annotations:
16
+ openshift.io/scc: anyuid
15
17
spec:
18
+ serviceAccountName: jupyter
19
+ securityContext:
20
+ fsGroup: 2000 # Allows shared access to config volume for group ID 2000
16
21
initContainers:
17
22
- name: copy-notebook-config
18
23
image: busybox
35
40
env:
36
41
- name: JUPYTER_TOKEN
37
42
value: "{{ jupyter_token }}"
43
+ securityContext:
44
+ runAsUser: 1000
45
+ runAsGroup: 2000
46
+ runAsNonRoot: true
47
+ allowPrivilegeEscalation: false
38
48
volumeMounts:
39
49
- name: notebook-storage
40
50
mountPath: {{ mount_path }}
Original file line number Diff line number Diff line change
1
+ ---
2
+ apiVersion: rbac.authorization.k8s.io/v1
3
+ kind: Role
4
+ metadata:
5
+ name: scc-anyuid
6
+ namespace: {{ namespace }}
7
+ rules:
8
+ - apiGroups: ['security.openshift.io']
9
+ resources: ['securitycontextconstraints']
10
+ verbs: ['use']
11
+ resourceNames: ['anyuid']
12
+
13
+ ---
14
+ apiVersion: rbac.authorization.k8s.io/v1
15
+ kind: RoleBinding
16
+ metadata:
17
+ name: jupyter-scc-anyuid-binding
18
+ namespace: {{ namespace }}
19
+ subjects:
20
+ - kind: ServiceAccount
21
+ name: jupyter
22
+ namespace: {{ namespace }}
23
+ roleRef:
24
+ kind: Role
25
+ name: scc-anyuid
26
+ apiGroup: rbac.authorization.k8s.io
Original file line number Diff line number Diff line change
1
+ apiVersion: v1
2
+ kind: ServiceAccount
3
+ metadata:
4
+ name: jupyter
5
+ namespace: {{ namespace }}
You can’t perform that action at this time.
0 commit comments