1
- import os , subprocess
1
+
2
2
3
3
from kubernetes import client
4
4
from kubernetes .client .rest import ApiException
@@ -190,6 +190,19 @@ def _init_eos_containers(self, eos_secret_name):
190
190
)
191
191
)
192
192
193
+ #the notebook container needs to run as root as it needs to
194
+ #add an user and switch to that user
195
+ #it also need to set command and args to none in order to
196
+ #run the systemuser.sh script as defined in the image
197
+ #(we set jupyterhub-singleuser in the values as that is what
198
+ #is needed for authenticated binder)
199
+
200
+ run_as_root = client .V1SecurityContext (run_as_user = 0 )
201
+
202
+ notebook_container .security_context = run_as_root
203
+ notebook_container .command = None
204
+ notebook_container .args = None
205
+
193
206
# add the base containers after side container (to start after side container)
194
207
existing_containers = self .pod .spec .containers
195
208
pod_spec_containers .extend (existing_containers )
@@ -200,11 +213,11 @@ def _init_eos_containers(self, eos_secret_name):
200
213
# https://jupyterhub-kubespawner.readthedocs.io/en/latest/spawner.html
201
214
# This is defined in the configuration to allow overring iindependently
202
215
# of which config file is loaded first
203
- # c.SwanKubeSpawner .modify_pod_hook = swan_pod_hook
216
+ # c.SwanSpawner .modify_pod_hook = swan_pod_hook
204
217
def swan_pod_hook_prod (spawner , pod ):
205
218
"""
206
219
:param spawner: Swan Kubernetes Spawner
207
- :type spawner: swanspawner.SwanKubeSpawner
220
+ :type spawner: swanspawner.SwanSpawner
208
221
:param pod: default pod definition set by jupyterhub
209
222
:type pod: client.V1Pod
210
223
@@ -219,7 +232,4 @@ def swan_pod_hook_prod(spawner, pod):
219
232
# Get configuration parameters from environment variables
220
233
swan_container_namespace = os .environ .get ('POD_NAMESPACE' , 'default' )
221
234
222
- c .SwanKubeSpawner .modify_pod_hook = swan_pod_hook_prod
223
-
224
- # Required for swan systemuser.sh
225
- c .SwanKubeSpawner .cmd = None
235
+ c .SwanSpawner .modify_pod_hook = swan_pod_hook_prod
0 commit comments