Skip to content

Instantly share code, notes, and snippets.

@jskeates
Last active September 30, 2019 22:06
Show Gist options
  • Save jskeates/62f5128388c863aa2946fbe71084aff5 to your computer and use it in GitHub Desktop.
Save jskeates/62f5128388c863aa2946fbe71084aff5 to your computer and use it in GitHub Desktop.
JupyterHub Demo Files

These are the configuration files used to setup the video demo shown in the presentation.

They use eksctl to setup a Kubernetes cluster with AWS EKS, and then Helm v2 to setup cluster components.

Note the cluster is hard-coded to eu-west-1a region & availability zone for simplicity, but this is not be suitable for a production setup.

# Install autoscaler using Helm https://github.com/helm/charts/tree/master/stable/cluster-autoscaler
# Replace <cluster-name> in this file with your eksctl cluster name
# helm upgrade --install cluster-autoscaler stable/cluster-autoscaler --namespace kube-system --values autoscaler.yaml
image:
tag: v1.16.1
autoDiscovery:
clusterName: <cluster-name>
awsRegion: eu-west-1
rbac:
create: true
nodeSelector:
role: main
# Install JupyterHub with Helm https://zero-to-jupyterhub.readthedocs.io/en/latest/setup-jupyterhub.html
# helm upgrade --install jupyter jupyterhub/jupyterhub --namespace jupyter --version=0.8.2 --values jupyterhub.yaml
# Setup Google auth as described in docs https://zero-to-jupyterhub.readthedocs.io/en/latest/authentication.html#google-oauth
auth:
type: google
google:
clientId: ""
clientSecret: ""
callbackUrl: ""
hostedDomain: ""
loginService: ""
proxy:
# Generate random secret token `openssl rand -hex 32`
secretToken: ""
https:
enabled: true
type: offload
service:
annotations:
# Certificate ARN, setup certificate in AWS ACM
service.beta.kubernetes.io/aws-load-balancer-ssl-cert: ""
# The protocol to use on the backend, we use TCP since we're using websockets
service.beta.kubernetes.io/aws-load-balancer-backend-protocol: "tcp"
# Which ports should use SSL
service.beta.kubernetes.io/aws-load-balancer-ssl-ports: "https"
service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout: "3600"
singleuser:
image:
name: jupyter/datascience-notebook
tag: 1386e2046833
profileList:
- display_name: "Large environment"
description: "R language in a large Spot Instance environment"
default: true
kubespawner_override:
cpu_guarantee: 1
mem_guarantee: "6G"
node_selector: # Links up with labels in nodes.yaml
size: large
pricing: spot
- display_name: "Extra Large environment"
description: "Python in a extra large Spot Instance environment"
kubespawner_override:
cpu_guarantee: 3
mem_guarantee: "14G"
node_selector:
size: xlarge
pricing: spot
- display_name: "Large On Demand environment"
description: "Python in a large On Demand environment"
kubespawner_override:
cpu_guarantee: 1
mem_guarantee: "6G"
node_selector:
size: large
pricing: on-demand
# Use eksctl to create an EKS cluster
# docs here https://eksctl.io/usage/creating-and-managing-clusters/
# replace <cluster-name> in this file with the name of your cluster
apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig
metadata:
name: <cluster-name>
region: eu-west-1
nodeGroups:
- name: main2
labels:
role: main
instanceType: t3.medium
desiredCapacity: 2
privateNetworking: true
availabilityZones:
- eu-west-1a
iam:
withAddonPolicies:
autoScaler: true
- name: ml-large-od-v3
privateNetworking: true
availabilityZones:
- eu-west-1a
minSize: 0
maxSize: 2
labels:
size: large
pricing: on-demand
instanceType: "m5.large"
tags:
"k8s.io/cluster-autoscaler/enabled": "true"
"k8s.io/cluster-autoscaler/<cluster-name>": "owned"
"k8s.io/cluster-autoscaler/node-template/label/size": "large"
"k8s.io/cluster-autoscaler/node-template/label/pricing": "on-demand"
- name: ml-large-v3
privateNetworking: true
availabilityZones:
- eu-west-1a
minSize: 0
maxSize: 2
labels:
size: large
pricing: spot
instancesDistribution: # Including this struct turns the pool into Spot Instances
instanceTypes: ["m5.large", "m4.large"]
onDemandBaseCapacity: 0
onDemandPercentageAboveBaseCapacity: 0
spotInstancePools: 1
tags:
"k8s.io/cluster-autoscaler/enabled": "true"
"k8s.io/cluster-autoscaler/<cluster-name>": "owned"
"k8s.io/cluster-autoscaler/node-template/label/size": "large"
"k8s.io/cluster-autoscaler/node-template/label/pricing": "spot"
- name: ml-xlarge-v4
availabilityZones:
- eu-west-1a
privateNetworking: true
minSize: 0
maxSize: 2
labels:
size: xlarge
pricing: spot
instancesDistribution:
instanceTypes: ["m5.xlarge", "m4.xlarge"]
onDemandBaseCapacity: 0
onDemandPercentageAboveBaseCapacity: 0
spotInstancePools: 1
tags:
"k8s.io/cluster-autoscaler/enabled": "true"
"k8s.io/cluster-autoscaler/<cluster-name>": "owned"
"k8s.io/cluster-autoscaler/node-template/label/size": "xlarge"
"k8s.io/cluster-autoscaler/node-template/label/pricing": "spot"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment