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 2020 stdin : " {{ lookup('template', 'pvc.yaml.j2') }}"
2121 executable : /bin/bash
2222
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+
2348- name : Deploy Jupyter Notebook
2449 ansible.builtin.shell : |
2550 kubectl apply -f -
Original file line number Diff line number Diff line change 2020 shell : kubectl delete configmap notebook-config -n {{ namespace }}
2121 ignore_errors : true
2222
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 1212 metadata:
1313 labels:
1414 app: jupyter-notebook
15+ annotations:
16+ openshift.io/scc: anyuid
1517 spec:
18+ serviceAccountName: jupyter
19+ securityContext:
20+ fsGroup: 2000 # Allows shared access to config volume for group ID 2000
1621 initContainers:
1722 - name: copy-notebook-config
1823 image: busybox
3540 env:
3641 - name: JUPYTER_TOKEN
3742 value: "{{ jupyter_token }}"
43+ securityContext:
44+ runAsUser: 1000
45+ runAsGroup: 2000
46+ runAsNonRoot: true
47+ allowPrivilegeEscalation: false
3848 volumeMounts:
3949 - name: notebook-storage
4050 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