2018-11-08 19:23:39 +05:30
|
|
|
rbac:
|
|
|
|
enabled: false
|
|
|
|
|
|
|
|
hub:
|
|
|
|
extraEnv:
|
|
|
|
JUPYTER_ENABLE_LAB: 1
|
|
|
|
extraConfig: |
|
|
|
|
c.KubeSpawner.cmd = ['jupyter-labhub']
|
2019-09-04 21:01:54 +05:30
|
|
|
c.GitLabOAuthenticator.scope = ['api read_repository write_repository']
|
|
|
|
|
|
|
|
async def add_auth_env(spawner):
|
|
|
|
'''
|
|
|
|
We set user's id, login and access token on single user image to
|
|
|
|
enable repository integration for JupyterHub.
|
|
|
|
See: https://gitlab.com/gitlab-org/gitlab-ce/issues/47138#note_154294790
|
|
|
|
'''
|
|
|
|
auth_state = await spawner.user.get_auth_state()
|
|
|
|
|
|
|
|
if not auth_state:
|
|
|
|
spawner.log.warning("No auth state for %s", spawner.user)
|
|
|
|
return
|
|
|
|
|
|
|
|
spawner.environment['GITLAB_ACCESS_TOKEN'] = auth_state['access_token']
|
|
|
|
spawner.environment['GITLAB_USER_LOGIN'] = auth_state['gitlab_user']['username']
|
|
|
|
spawner.environment['GITLAB_USER_ID'] = str(auth_state['gitlab_user']['id'])
|
|
|
|
spawner.environment['GITLAB_USER_EMAIL'] = auth_state['gitlab_user']['email']
|
|
|
|
spawner.environment['GITLAB_USER_NAME'] = auth_state['gitlab_user']['name']
|
|
|
|
|
|
|
|
c.KubeSpawner.pre_spawn_hook = add_auth_env
|
2018-11-08 19:23:39 +05:30
|
|
|
|
|
|
|
auth:
|
|
|
|
type: gitlab
|
2019-09-04 21:01:54 +05:30
|
|
|
state:
|
|
|
|
enabled: true
|
2018-11-08 19:23:39 +05:30
|
|
|
|
|
|
|
singleuser:
|
|
|
|
defaultUrl: "/lab"
|
2019-09-04 21:01:54 +05:30
|
|
|
image:
|
|
|
|
name: registry.gitlab.com/gitlab-org/jupyterhub-user-image
|
|
|
|
tag: latest
|
2018-12-05 23:21:45 +05:30
|
|
|
lifecycleHooks:
|
|
|
|
postStart:
|
|
|
|
exec:
|
2019-09-04 21:01:54 +05:30
|
|
|
command:
|
|
|
|
- "sh"
|
|
|
|
- "-c"
|
|
|
|
- >
|
|
|
|
git clone https://gitlab.com/gitlab-org/nurtch-demo.git DevOps-Runbook-Demo || true;
|
2019-09-30 21:07:59 +05:30
|
|
|
echo "https://oauth2:${GITLAB_ACCESS_TOKEN}@${GITLAB_HOST}" > ~/.git-credentials;
|
2019-09-04 21:01:54 +05:30
|
|
|
git config --global credential.helper store;
|
|
|
|
git config --global user.email "${GITLAB_USER_EMAIL}";
|
|
|
|
git config --global user.name "${GITLAB_USER_NAME}";
|
|
|
|
jupyter serverextension enable --py jupyterlab_git
|
2018-11-08 19:23:39 +05:30
|
|
|
|
|
|
|
ingress:
|
|
|
|
enabled: true
|
|
|
|
annotations:
|
|
|
|
kubernetes.io/ingress.class: "nginx"
|
2019-02-15 15:39:39 +05:30
|
|
|
kubernetes.io/tls-acme: "true"
|