Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MRG] Adding Turing cluster to the Federation #1203

Merged
merged 72 commits into from
Jan 15, 2020
Merged
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
e5aa421
Ignore vscode settings
sgibson91 Oct 15, 2019
3042925
Add Turing config file
sgibson91 Oct 15, 2019
3803833
Add turing_mybinder_org_ingress.yaml file
sgibson91 Oct 15, 2019
3c8b681
Filling in config/turing.yaml
sgibson91 Oct 15, 2019
34a13c8
Add turing secrets
sgibson91 Oct 16, 2019
2f46a52
Add turing k8s auth to deploy.py
sgibson91 Oct 16, 2019
740a190
Correct path to Azure auth key file
sgibson91 Oct 16, 2019
91084fa
Add Turing cluster to Travis deployment:
sgibson91 Oct 16, 2019
b4ce725
Update .travis.yml
sgibson91 Oct 16, 2019
d36d083
Remove turing ingress yaml file
sgibson91 Oct 22, 2019
b04b5ef
Remove unnecessary keys from turing.yaml
sgibson91 Oct 22, 2019
53ff293
Replacing subdomains with temp ones
sgibson91 Oct 22, 2019
c160858
Correct dict key in deploy.py
sgibson91 Oct 22, 2019
16d4058
Correct args to deploy.py
sgibson91 Oct 22, 2019
32cf222
Expose configMap as variable to secret/ban.py
sgibson91 Oct 22, 2019
a33d1b4
Updating deploy.py and ban.py
sgibson91 Oct 22, 2019
bebd871
Merge branch 'master' into sgibson91/add-turing-to-federation
sgibson91 Oct 22, 2019
47efb4b
Revert "Remove unnecessary keys from turing.yaml"
sgibson91 Oct 22, 2019
c876f7a
Revert "Remove turing ingress yaml file"
sgibson91 Oct 22, 2019
ea9cf37
Update secrets/ban.py to match master branch
sgibson91 Nov 25, 2019
f3a13f7
Merge branch 'master' into sgibson91/add-turing-to-federation
sgibson91 Nov 25, 2019
2f9eac5
Remove vscode from .gitignore
sgibson91 Nov 25, 2019
0e52984
Updating secrets/ban.py for turing cluster
sgibson91 Nov 25, 2019
b31a8bd
Update turing config
sgibson91 Nov 25, 2019
d627123
Add empty serviceAccountField for matomo
sgibson91 Nov 26, 2019
c201d2f
Add missing arg to func in deploy.py
sgibson91 Nov 26, 2019
0c6ecdf
Remove events-archiver-secrets volume mount
sgibson91 Nov 26, 2019
ae5fc80
Remove turing ingress yaml
sgibson91 Nov 26, 2019
be56858
Revert "Remove events-archiver-secrets volume mount"
sgibson91 Nov 26, 2019
5c6fdc7
Tweaking Turing
betatim Nov 29, 2019
ca690ef
Update mybinder/requirements.yaml
betatim Nov 29, 2019
ce237c9
Merge pull request #1283 from betatim/turing-tweaking
sgibson91 Dec 2, 2019
7f36411
Remove temp return line
sgibson91 Dec 2, 2019
daa9e1d
Reduce turing pod quota
sgibson91 Dec 3, 2019
e584920
Change turing domain name
sgibson91 Dec 6, 2019
fcca53d
Add certmanager cluster issuer
sgibson91 Dec 6, 2019
a607a18
Add lets encrypt contact email to turing config
sgibson91 Dec 6, 2019
1af09a3
Delete cluster issuer
sgibson91 Dec 6, 2019
f300d01
Use letsencrypt-staging in turing config
sgibson91 Dec 6, 2019
02d07bf
Add cert-manager cluster issuer file
sgibson91 Dec 6, 2019
8bff176
Configure certmanager
sgibson91 Dec 6, 2019
ab79ae3
Configure lets encrypt staging
sgibson91 Dec 6, 2019
6ecab8e
Configure prod lets encrypt
sgibson91 Dec 6, 2019
bc1d204
Include turing cluster in the federation
sgibson91 Dec 6, 2019
1b2214c
Merge branch 'master' into sgibson91/add-turing-to-federation
sgibson91 Dec 6, 2019
f93b9f0
Neaten up deploy.py
sgibson91 Dec 6, 2019
e9d81ca
Add ingress file for redirection to turing.mybinder.org
sgibson91 Dec 10, 2019
603ff21
Rename turing secrets
sgibson91 Dec 10, 2019
660a71d
Update turing hostname in values
sgibson91 Dec 10, 2019
c87ee4e
Add turing.mybinder.org host
sgibson91 Dec 10, 2019
37b18c2
Merge branch 'master' into sgibson91/add-turing-to-federation
sgibson91 Dec 11, 2019
56d2c80
Remove if statement in deploy.py
sgibson91 Dec 11, 2019
2026451
Temporarily change letsencrypt issuer to staging
sgibson91 Dec 11, 2019
922164b
Remove playground and beta hosts
sgibson91 Dec 11, 2019
4785290
Remove ingress shim for certmanager
sgibson91 Dec 11, 2019
5ac8f08
Move cluster issuer into templates folder
sgibson91 Dec 11, 2019
6c3c3ff
Remove ingress config
sgibson91 Dec 11, 2019
4810127
Add if statements to cluster issuer file
sgibson91 Dec 11, 2019
d3f6393
Correct cluster issuer syntax
sgibson91 Dec 11, 2019
c0710f8
Undo if statements in cluster issuer
sgibson91 Dec 11, 2019
d1d1b64
Re-add if statements to cluster issuer file
sgibson91 Dec 11, 2019
912b6ca
Change certificates back to prod
sgibson91 Dec 11, 2019
2c4c10d
Rearrange annotations
sgibson91 Dec 11, 2019
9be810f
Rearrange if statement in cluster issuer
sgibson91 Dec 11, 2019
8a843ac
Change turing A records
sgibson91 Dec 12, 2019
c3f8621
Merge branch 'master' into sgibson91/add-turing-to-federation
sgibson91 Jan 6, 2020
8485ee5
Correct hub url for turing cluster in travis config
sgibson91 Jan 6, 2020
20bf03e
Update host and secret names
sgibson91 Jan 6, 2020
812e82c
Update step numbers in travis config
sgibson91 Jan 7, 2020
0cb52cf
Enable https to fix lets encrypt
sgibson91 Jan 7, 2020
3a7c999
Issue certificates for grafana
sgibson91 Jan 7, 2020
08959f7
Add grafana admin password to turing secrets config
sgibson91 Jan 10, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ before_deploy:
- |
# Stage 1: Install gcloud SDK
curl -L https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-173.0.0-linux-x86_64.tar.gz | tar --directory ${HOME} --extract --gzip --file -
- |
# Stage 1: Install Azure CLI
curl -L https://aka.ms/InstallAzureCli | bash
- |
# Stage 1: Install Kubectl
mkdir -p ${HOME}/bin
Expand Down Expand Up @@ -59,6 +62,7 @@ before_deploy:
# Stage 2, Step 2: Set up helm!
helm init --client-only
helm repo add jupyterhub https://jupyterhub.github.io/helm-chart
helm repo add jetstack https://charts.jetstack.io
helm repo update
(cd mybinder && helm dep up)
- |
Expand Down Expand Up @@ -90,12 +94,18 @@ before_deploy:
- |
# Stage 5, Step 3: Deploy to production on ovh k8s
python ./deploy.py ovh binder-ovh
- |
# Stage 5, Step 4: Deploy to production on Turing k8s
python ./deploy.py turing turing
sgibson91 marked this conversation as resolved.
Show resolved Hide resolved
- |
# Stage 5, Step 4: Verify production works
travis_retry py.test -vx -n 2 --binder-url=https://gke.mybinder.org --hub-url=https://hub.gke.mybinder.org
- |
# Stage 5, Step 5: Verify production on ovh k8s works
travis_retry py.test -vx -n 2 --binder-url=https://ovh.mybinder.org --hub-url=https://hub-binder.mybinder.ovh
- |
# Stage 5, Step 6: Verify production on Turing k8s works
travis_retry py.test -vx -n 2 --binder-url=https://turing.mybinder.org --hub-url=https://hub.turing.mybinder.org
sgibson91 marked this conversation as resolved.
Show resolved Hide resolved


env:
Expand Down
3 changes: 2 additions & 1 deletion config/staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,6 @@ federationRedirect:
weight: 1
health: https://gke2.staging.mybinder.org/health
versions: https://gke2.staging.mybinder.org/versions
# unset the gesis entry
# unset the gesis and turing entries
gesis: null
turing: null
203 changes: 203 additions & 0 deletions config/turing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
projectName: turing

tags:
kubelego: false
certmanager: true

letsencrypt:
contactEmail: drsarahlgibson@gmail.com

binderhub:
extraConfig:
01-eventlog: ""
config:
BinderHub:
pod_quota: 20
hub_url: http://testhub.hub23.turing.ac.uk
sgibson91 marked this conversation as resolved.
Show resolved Hide resolved
badge_base_url: https://mybinder.org
image_prefix: turingmybinderregistry.azurecr.io/binder-prod/binder-prod-
sticky_builds: true
DockerRegistry:
token_url: https://turingmybinderregistry.azurecr.io/oauth2/token?service=turingmybinderregistry.azurecr.io
registry:
url: https://turingmybinderregistry.azurecr.io

replicas: 1

resources:
requests:
cpu: "0.25"
memory: 1Gi
limits:
cpu: "2"
memory: 1Gi

ingress:
hosts:
- testbinder.hub23.turing.ac.uk
sgibson91 marked this conversation as resolved.
Show resolved Hide resolved
annotations:
kubernetes.io/ingress.class: nginx
cert-manager.io/cluster-issuer: letsencrypt-prod
kubernetes.io/tls-acme: "true"
tls:
- secretName: tls-crt
hosts:
- testbinder.hub23.turing.ac.uk

jupyterhub:
hub:
resources:
requests:
cpu: "0.25"
memory: 1Gi
limits:
cpu: "2"
memory: 1Gi
singleuser:
memory:
guarantee: 550M
limit: 2G
cpu:
guarantee: 0.01
limit: 1
proxy:
chp:
resources:
requests:
memory: 320Mi
cpu: "0.1"
limits:
memory: 320Mi
cpu: "0.5"
nginx:
resources:
requests:
memory: 512Mi
cpu: "0.25"
limits:
memory: 512Mi
cpu: 1

ingress:
annotations:
kubernetes.io/ingress.class: nginx
cert-manager.io/cluster-issuer: letsencrypt-prod
kubernetes.io/tls-acme: "true"
betatim marked this conversation as resolved.
Show resolved Hide resolved
hosts:
- testhub.hub23.turing.ac.uk
tls:
- secretName: tls-crt
hosts:
- testhub.hub23.turing.ac.uk

scheduling:
userScheduler:
enabled: false
podPriority:
enabled: true
userPlaceholder:
enabled: true
replicas: 5

grafana:
ingress:
annotations:
kubernetes.io/ingress.class: nginx
sgibson91 marked this conversation as resolved.
Show resolved Hide resolved
kubernetes.io/tls-acme: 'true'
hosts:
- grafana.hub23.turing.ac.uk
tls:
- secretName: tls-crt
hosts:
- grafana.hub23.turing.ac.uk

datasources:
datasources.yaml:
apiVersion: 1
datasources:
- name: prometheus
orgId: 1
type: prometheus
url: https://prometheus.hub23.turing.ac.uk
access: direct
isDefault: true
editable: false

prometheus:
server:
ingress:
annotations:
kubernetes.io/ingress.class: nginx
kubernetes.io/tls-acme: 'false'
hosts:
- prometheus.hub23.turing.ac.uk
tls:
- hosts:
- prometheus.hub23.turing.ac.uk
secretName: tls-crt


nginx-ingress:
controller:
service:
loadBalancerIP: 51.105.186.97
config:
proxy-body-size: 64m


static:
ingress:
annotations:
kubernetes.io/ingress.class: nginx
kubernetes.io/tls-acme: 'false'
hosts:
- static-turing.10.0.0.1.xip.io
tls:
- hosts:
- static-turing.10.0.0.1.xip.io
secretName: tls-crt

redirector:
redirects:
- type: host
betatim marked this conversation as resolved.
Show resolved Hide resolved
host:
from: beta-binder.turing.10.0.0.1.xip.io
to: turing.10.0.0.1.xip.io
- type: host
host:
from: docs-mybinder.turing.10.0.0.1.xip.io
to: mybinder.readthedocs.io
- type: host
betatim marked this conversation as resolved.
Show resolved Hide resolved
host:
from: playground-turing.10.0.0.1.xip.io
to: play.nteract.io

matomo:
enabled: false
db:
instanceName: binder-staging:us-central1:matomo
serviceAccountKey: ""
trustedHosts:
- staging-mybinder.turing.10.0.0.1.xip.io
ingress:
hosts:
- staging-mybinder.turing.10.0.0.1.xip.io

analyticsPublisher:
enabled: false
project: binder-turing
events:
sourceBucket: mybinder-staging-events-raw-export
destinationBucket: mybinder-staging-events-archive

gcsProxy:
enabled: false
buckets:
- name: mybinder-staging-events-archive
host: archive-analytics-staging-mybinder.turing.10.0.0.1.xip.io

certmanager:
ingressShim:
betatim marked this conversation as resolved.
Show resolved Hide resolved
defaultIssuerName: "prod"
defaultIssuerKind: "ClusterIssuer"
defaultACMEChallengeType: "http01"
48 changes: 43 additions & 5 deletions deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,35 @@
ABSOLUTE_HERE = os.path.dirname(os.path.realpath(__file__))


def setup_auth_turing(cluster):
"""
Set up athentication with Turing k8s cluster on Azure.
"""
# Read in auth info
azure_file = os.path.join(ABSOLUTE_HERE, "secrets", "turing-auth-key-prod.json")
with open(azure_file, "r") as stream:
azure = json.load(stream)

# Login in to Azure
login_cmd = [
"az", "login", "--service-principal",
"--username", azure["sp-app-id"],
"--password", azure["sp-app-key"],
"--tenant", azure["tenant-id"]
]
subprocess.check_output(login_cmd)

# Set kubeconfig
creds_cmd = [
"az", "aks", "get-credentials",
"--name", cluster,
"--resource-group", "binder-prod"

]
stdout = subprocess.check_output(creds_cmd)
print(stdout.decode('utf-8'))


def setup_auth_ovh(release, cluster):
"""
Set up authentication with 'binder-ovh' K8S from the ovh-kubeconfig.yml
Expand Down Expand Up @@ -119,10 +148,17 @@ def setup_helm(release):
def deploy(release):
"""Deploy jupyterhub"""
print(BOLD + GREEN + f"Updating network-bans for {release}" + NC, flush=True)
subprocess.check_call([
"python3",
"secrets/ban.py",
])
if release == "turing":
betatim marked this conversation as resolved.
Show resolved Hide resolved
subprocess.check_call([
"python3",
"secrets/ban.py",
release,
])
else:
subprocess.check_call([
"python3",
"secrets/ban.py",
])

print(BOLD + GREEN + f"Starting helm upgrade for {release}" + NC, flush=True)
helm = [
Expand Down Expand Up @@ -170,7 +206,7 @@ def main():
argparser.add_argument(
'release',
help="Release to deploy",
choices=['staging', 'prod', 'ovh']
choices=['staging', 'prod', 'ovh', 'turing']
)
argparser.add_argument(
'cluster',
Expand All @@ -181,6 +217,8 @@ def main():

if args.cluster == 'binder-ovh':
setup_auth_ovh(args.release, args.cluster)
elif args.cluster == 'turing':
setup_auth_turing(args.cluster)
else:
setup_auth_gcloud(args.release, args.cluster)

Expand Down
32 changes: 32 additions & 0 deletions mybinder/cluster-issuer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
sgibson91 marked this conversation as resolved.
Show resolved Hide resolved
apiVersion: cert-manager.io/v1alpha2
kind: ClusterIssuer
metadata:
name: letsencrypt-staging
namespace: turing
spec:
acme:
server: https://acme-staging-v02.api.letsencrypt.org/directory
email: drsarahlgibson@gmail.com
privateKeySecretRef:
name: letsencrypt-staging
solvers:
- http01:
ingress:
class: nginx
---
apiVersion: cert-manager.io/v1alpha2
kind: ClusterIssuer
metadata:
name: letsencrypt-prod
namespace: turing
spec:
acme:
server: https://acme-v02.api.letsencrypt.org/directory
email: drsarahlgibson@gmail.com
privateKeySecretRef:
name: letsencrypt-prod
solvers:
- http01:
ingress:
class: nginx
7 changes: 7 additions & 0 deletions mybinder/requirements.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ dependencies:
- name: kube-lego
version: 0.4.2
repository: https://kubernetes-charts.storage.googleapis.com
tags:
- kubelego
- name: cert-manager
version: v0.12.0-beta.1
repository: https://charts.jetstack.io
tags:
- certmanager
- name: binderhub
version: 0.2.0-045.089702b
repository: https://jupyterhub.github.io/helm-chart
10 changes: 9 additions & 1 deletion mybinder/values.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
tags:
kubelego: true

etcJupyter:
jupyter_notebook_config.json:
NotebookApp:
Expand Down Expand Up @@ -416,7 +419,7 @@ federationRedirect:
hosts:
gke:
url: https://gke.mybinder.org
weight: 66
weight: 65
health: https://gke.mybinder.org/health
versions: https://gke.mybinder.org/versions
prime: true
Expand All @@ -430,3 +433,8 @@ federationRedirect:
weight: 15
health: https://gesis.mybinder.org/health
versions: https://gesis.mybinder.org/versions
turing:
url: https://testbinder.hub23.turing.ac.uk
weight: 1
sgibson91 marked this conversation as resolved.
Show resolved Hide resolved
health: https://testbinder.hub23.turing.ac.uk/health
versions: https://testbinder.hub23.turing.ac.uk/versions
Binary file modified secrets/ban.py
Binary file not shown.
Binary file added secrets/config/turing.yaml
Binary file not shown.
Binary file added secrets/turing-auth-key-prod.json
Binary file not shown.