Skip to content

Commit

Permalink
add RStudio launch
Browse files Browse the repository at this point in the history
  • Loading branch information
rokroskar committed Sep 24, 2018
1 parent 1ec0d57 commit 66b0f53
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 6 deletions.
10 changes: 10 additions & 0 deletions helm-chart/chartpress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,13 @@ charts:
paths:
- ../singleuser
- ..
singleuser-r:
contextPath: ../singleuser
buildArgs:
JUPYTERHUB_VERSION: "0.9.2"
RENKU_VERSION: "0.2.0rc1"
dockerfilePath: ../singleuser/R.Dockerfile
valuesPath: jupyterhub.singleuser-r.image
paths:
- ../singleuser
- ..
6 changes: 6 additions & 0 deletions helm-chart/renku-notebooks/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ spec:
- name: FLASK_DEBUG
value: "1"
{{ end }}
{{ if .Values.jupyterhub.singleuser.defaultUrl }}
- name: JUPYTER_DEFAULT_URL
value: {{ .Values.jupyterhub.singleuser.defaultUrl }}
{{ end }}
- name: JUPYTERHUB_API_TOKEN
value: {{ .Values.jupyterhub_api_token }}
- name: JUPYTERHUB_API_URL
Expand All @@ -54,6 +58,8 @@ spec:
{{ else }}
value: {{ template "notebooks.http" . }}://{{ .Values.global.renku.domain}}/gitlab
{{ end }}
- name: IMAGE_REGISTRY
value: {{ .Values.imageRegistry }}
ports:
- name: http
containerPort: 8000
Expand Down
10 changes: 6 additions & 4 deletions helm-chart/renku-notebooks/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ image:
# pullSecrets:
# - myRegistrKeySecretName

## Set these values to correspond to the JupyterHub setup
# jupyterhub_api_token: notebookstoken
# jupyterhub_base_url: /
# jupyterhub_api_url: http://<host>/hub/api
## Set the default image registry
# imageRegistry:

# enable the security context - if using telepresence for development, disable it
securityContext:
Expand Down Expand Up @@ -143,6 +141,10 @@ jupyterhub:
storage:
type: none
defaultUrl: /lab
singleuser-r:
image:
name: renku/singleuser-r
tag: 'latest'
# FIXME: bug in prepuller makes helm hang in certain cases. Fixed in 0.7
# so this should be removed eventually.
# https://github.com/jupyterhub/zero-to-jupyterhub-k8s/issues/477
Expand Down
1 change: 1 addition & 0 deletions jupyterhub/spawners.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def start(self, *args, **kwargs):
commit_sha = options.get('commit_sha')
commit_sha_7 = commit_sha[:7]
self.image = options.get('image')
self.default_url = options.get('default_url')

url = os.getenv('GITLAB_URL', 'http://gitlab.renku.build')

Expand Down
2 changes: 1 addition & 1 deletion singleuser/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Build as renku/singleuser
# Run with the DockerSpawner in JupyterHub

ARG JUPYTERHUB_VERSION=0.9.1
ARG JUPYTERHUB_VERSION=0.9.2
ARG BASE_IMAGE=jupyterhub/singleuser:$JUPYTERHUB_VERSION

FROM $BASE_IMAGE
Expand Down
11 changes: 10 additions & 1 deletion src/notebooks_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
GITLAB_URL = os.environ.get('GITLAB_URL', 'https://gitlab.com')
"""The GitLab instance to use."""

IMAGE_REGISTRY = os.environ.get('IMAGE_REGISTRY', '')
"""The default image registry."""

SERVER_STATUS_MAP = {'spawn': 'spawning', 'stop': 'stopping'}

# check if we are running on k8s
Expand Down Expand Up @@ -277,7 +280,7 @@ def get_notebook_image(user, namespace, project, commit_sha):
# it *should* be there so lets use it
image = '{image_registry}/{namespace}'\
'/{project}:{commit_sha_7}'.format(
image_registry=os.getenv('IMAGE_REGISTRY'),
image_registry=IMAGE_REGISTRY,
commit_sha_7=commit_sha_7,
namespace=namespace,
project=project
Expand Down Expand Up @@ -378,17 +381,23 @@ def launch_notebook(user, namespace, project, commit_sha, notebook=None):
# 1. launch using spawner that checks the access
headers = {auth.auth_header_name: 'token {0}'.format(auth.api_token)}

# if there is an image passed with the request, use it
image = request.args.get(
'image', get_notebook_image(user, namespace, project, commit_sha)
)

default_url = request.args.get(
'default_url', os.environ.get('JUPYTER_DEFAULT_URL')
)

payload = {
'branch': request.args.get('branch', 'master'),
'commit_sha': commit_sha,
'namespace': namespace,
'notebook': notebook,
'project': project,
'image': image,
'default_url': default_url,
}
if os.environ.get('GITLAB_REGISTRY_SECRET'):
payload['image_pull_secrets'] = payload.get('image_pull_secrets', [])
Expand Down

0 comments on commit 66b0f53

Please sign in to comment.