diff --git a/helm-charts/basehub/values.yaml b/helm-charts/basehub/values.yaml index 0a11cdb63d..2afa411dff 100644 --- a/helm-charts/basehub/values.yaml +++ b/helm-charts/basehub/values.yaml @@ -577,12 +577,16 @@ jupyterhub: memory: 2Gi extraConfig: 01-custom-theme: | + # adds a JupyterHub template path and updates template variables + from z2jh import get_config c.JupyterHub.template_paths.insert(0,'/usr/local/share/jupyterhub/custom_templates') c.JupyterHub.template_vars.update({ 'custom': get_config('custom.homepage.templateVars') }) 02-custom-admin: | + # adjusts the spawner to add config specific to admin users + from z2jh import get_config from kubespawner import KubeSpawner from jupyterhub_configurator.mixins import ConfiguratorSpawnerMixin @@ -590,14 +594,18 @@ jupyterhub: class CustomSpawner(ConfiguratorSpawnerMixin, KubeSpawner): def start(self, *args, **kwargs): custom_admin = get_config('custom.singleuserAdmin', {}) - if custom_admin and self.user.admin: - extra_init_containers = custom_admin.get('initContainers', []) - extra_volume_mounts = custom_admin.get('extraVolumeMounts', []) - extra_env = custom_admin.get('extraEnv', {}) - - self.init_containers += [container for container in extra_init_containers if container not in self.init_containers] - self.volume_mounts += [volume for volume in extra_volume_mounts if volume not in self.volume_mounts] - self.environment.update(extra_env) + if not (self.user.admin and custom_admin): + return super().start(*args, **kwargs) + + admin_volume_mounts = custom_admin.get('extraVolumeMounts', []) + self.volume_mounts += [vm for vm in admin_volume_mounts if vm not in self.volume_mounts] + + admin_environment = custom_admin.get('extraEnv', {}) + self.environment.update(admin_environment) + + admin_service_account = custom_admin.get('serviceAccountName'): + if admin_service_account: + self.service_account = admin_service_account return super().start(*args, **kwargs)