Skip to content

Commit 37e47d2

Browse files
committed
Add the helmchart components to this repository from https://github.com/ml-tooling/zero-to-mlhub-k8s
1 parent 0a06d22 commit 37e47d2

34 files changed

+2212
-37
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,6 @@ hs_err_pid*
4949
*.log
5050
*.swp
5151
temp/*
52-
.DS_Store
52+
.DS_Store
53+
54+
helmchart/*.tgz

Dockerfile

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -106,20 +106,21 @@ RUN \
106106
### INCUBATION ZONE ###
107107

108108
# Kubernetes Support
109-
ADD https://raw.githubusercontent.com/ml-tooling/zero-to-mlhub-k8s/master/images/hub/z2jh.py /usr/local/lib/python3.6/dist-packages/z2jh.py
110109
ADD https://raw.githubusercontent.com/ml-tooling/zero-to-mlhub-k8s/master/images/hub/cull_idle_servers.py /usr/local/bin/cull_idle_servers.py
110+
ADD resources/kubernetes/jupyterhub_chart_config.py $_RESOURCES_PATH/jupyterhub_chart_config.py
111111
# Copy the jupyterhub config that has a lot of options to be configured
112-
ADD https://raw.githubusercontent.com/ml-tooling/zero-to-mlhub-k8s/master/images/hub/jupyterhub_config.py $_RESOURCES_PATH/kubernetes/jupyterhub_chart_config.py
113-
ADD https://raw.githubusercontent.com/ml-tooling/zero-to-mlhub-k8s/master/images/hub/requirements.txt /tmp/requirements.txt
114112

115-
RUN PYCURL_SSL_LIBRARY=openssl pip3 install --no-cache-dir \
116-
-r /tmp/requirements.txt && \
117-
chmod u+rx /usr/local/bin/cull_idle_servers.py && \
118-
chmod u+rx /usr/local/lib/python3.6/dist-packages/z2jh.py && \
119-
# Cleanup
120-
clean-layer.sh
121-
122-
RUN pip3 install oauthenticator psutil
113+
RUN chmod u+rx /usr/local/bin/cull_idle_servers.py
114+
115+
RUN pip3 install oauthenticator psutil yamlreader pyjwt \
116+
# https://github.com/jupyterhub/kubespawner
117+
# https://pypi.org/project/jupyterhub-kubespawner
118+
jupyterhub-kubespawner==0.11.* \
119+
# https://github.com/kubernetes-client/python
120+
# https://pypi.org/project/kubernetes
121+
kubernetes==10.0.* \
122+
# https://pypi.org/project/pycurl/
123+
pycurl==7.43.0.*
123124
RUN apt-get update && apt-get install -y pcregrep && clean-layer.sh
124125

125126
### END INCUBATION ZONE ###

README.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ MLHub is based on [JupyterHub](https://github.com/jupyterhub/jupyterhub) with co
3939

4040
- MLHub can be configured like JupyterHub with a normal JupyterHub configuration, with minor adjustments in the Kubernetes scenario.
4141
- The documentation provides an overview of how to use and configure it in Docker-local and Kubernetes mode.
42-
- More information about the Helm chart resources for Kubernetes can be found [here](https://github.com/ml-tooling/zero-to-mlhub-k8s).
42+
- More information about the Helm chart resources for Kubernetes can be found [here](https://github.com/ml-tooling/ml-hub/tree/master/helmchart).
4343
- We created two custom Spawners that are based on the official [DockerSpawner](https://github.com/jupyterhub/dockerspawner) and [KubeSpawner](https://github.com/jupyterhub/kubespawner) and, hence, support their configurations set via the JupyterHub config.
4444

4545
## Getting Started
@@ -74,7 +74,7 @@ Via Helm:
7474
RELEASE=mlhub # change if needed
7575
NAMESPACE=$RELEASE # change if needed
7676

77-
helm upgrade --install $RELEASE mlhub-chart-1.0.1.tgz --namespace $NAMESPACE
77+
helm upgrade --install $RELEASE mlhub-chart-2.0.0.tgz --namespace $NAMESPACE
7878

7979
# In case you just want to use the templating mechanism of Helm without deploying tiller on your cluster
8080
# 1. Use the "helm template ..." command. The template command also excepts flags such as --config and --set-file as described in the respective Sections in this documentation.
@@ -184,7 +184,7 @@ mlhub:
184184
</details>
185185

186186
You can pass the file via `--values config.yaml`. The complete command would look like `helm upgrade --install mlhub mlhub-chart-1.0.1.tgz --namespace mlhub --values config.yaml`. The `--set-file userConfig=./jupyterhub_user_config.py` flag can additionally be set.
187-
You can find the Helm chart resources in the repository [zero-to-mlhub-with-kubernetes](https://github.com/ml-tooling/zero-to-mlhub-k8s); the [values file](https://github.com/ml-tooling/zero-to-mlhub-k8s/blob/master/jupyterhub/values.yaml) contains the default values for the deployment.
187+
You can find the Helm chart resources, including the values file that contains the default values, in the directory `helmchart`).
188188

189189
### Enable SSL/HTTPS
190190

@@ -206,7 +206,7 @@ For Kubernetes, add following lines to the `config.yaml` file (based on [setup-m
206206

207207
```yaml
208208

209-
config:
209+
mlhub:
210210
env:
211211
SSL_ENABLED: true
212212

@@ -396,19 +396,18 @@ Via the START\_* environment variables you can define what is started within the
396396
</tr>
397397
<tr>
398398
<td>START_NGINX</td>
399-
<td>Whether or not to start the nginx proxy. If the Hub should be used without additional tool routing to workspaces, this could be disabled. SSH port 22 would need to be published separately then. This option is built-in to work with <a href="https://github.com/ml-tooling/zero-to-mlhub-k8s"> zero-to-mlhub-k8s</a>
399+
<td>Whether or not to start the nginx proxy. If the Hub should be used without additional tool routing to workspaces, this could be disabled. SSH port 22 would need to be published separately then. This option is built-in to work with our Kubernetes Helm chart.
400400
</td>
401401
<td>true</td>
402402
</tr>
403403
<tr>
404404
<td>START_JHUB</td>
405-
<td>Start the JupyterHub hub. This option is built-in to work with
406-
<a href="https://github.com/ml-tooling/zero-to-mlhub-k8s"> zero-to-mlhub-k8s</a>, where the image is also used as the CHP image.</td>
405+
<td>Start the JupyterHub hub.</td>
407406
<td>true</td>
408407
</tr>
409408
<tr>
410409
<td>START_CHP</td>
411-
<td>Start the JupyterHub proxy process separately (The hub should not start the proxy itself, which can be configured via the JupyterHub config file. This option is built-in to work with <a href="https://github.com/ml-tooling/zero-to-mlhub-k8s"> zero-to-mlhub-k8s</a>, where the image is also used as the Configurable-Http-Proxy (CHP) image. Additional arguments to the chp-start command can be passed to the container by passing an environment variable ADDITIONAL_ARGS, e.g. --env ADDITIONAL_ARGS="--ip=0.0.0.0 --api-ip=0.0.0.0".</td>
410+
<td>Start the JupyterHub proxy process separately (The hub should not start the proxy itself, which can be configured via the JupyterHub config file. This option is built-in to work with our Kubernetes Helm chart, where the image is also used as the Configurable-Http-Proxy (CHP) image. Additional arguments to the chp-start command can be passed to the container by passing an environment variable ADDITIONAL_ARGS, e.g. --env ADDITIONAL_ARGS="--ip=0.0.0.0 --api-ip=0.0.0.0".</td>
412411
<td>false</td>
413412
</tr>
414413
</table>

build.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,25 @@ def build(module="."):
8484

8585
if "SNAPSHOT" not in args.version:
8686
# do not push SNAPSHOT builds as latest version
87-
call("docker push " + remote_latest_image)
87+
call("docker push " + remote_latest_image)
88+
89+
# Create the Helm chart resource
90+
import fileinput
91+
92+
chart_yaml = "./helmchart/mlhub/Chart.yaml"
93+
values_yaml = "./helmchart/mlhub/values.yaml"
94+
with fileinput.FileInput(chart_yaml, inplace=True, backup='.bak') as file:
95+
for line in file:
96+
print(line.replace("$VERSION", str(args.version)), end='')
97+
98+
with fileinput.FileInput(values_yaml, inplace=True, backup='.bak') as file:
99+
for line in file:
100+
print(line.replace("$VERSION", str(args.version)), end='')
101+
102+
try:
103+
call("helm package ./helmchart/mlhub -d helmchart")
104+
except:
105+
print("There was a problem with the helm command")
106+
107+
os.replace(f"{chart_yaml}.bak", chart_yaml)
108+
os.replace(f"{values_yaml}.bak", values_yaml)

0 commit comments

Comments
 (0)