Skip to content

Commit

Permalink
sync only in between computers
Browse files Browse the repository at this point in the history
  • Loading branch information
consideRatio committed Aug 6, 2018
1 parent 439e2bb commit e968490
Show file tree
Hide file tree
Showing 23 changed files with 489 additions and 257 deletions.
56 changes: 56 additions & 0 deletions .circleci/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Python CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-python/ for more details
#
version: 2
jobs:
build:
docker:
# specify the version you desire here
# use `-browsers` prefix for selenium tests, e.g. `3.6.1-browsers`
- image: circleci/python:3.6.1

# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
# - image: circleci/postgres:9.4

working_directory: ~/repo

steps:
- checkout

# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "requirements.txt" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

- run:
name: install dependencies
command: |
python3 -m venv venv
. venv/bin/activate
pip install -r requirements.txt
- save_cache:
paths:
- ./venv
key: v1-dependencies-{{ checksum "requirements.txt" }}

# run tests!
# this example uses Django's built-in test-runner
# other common Python testing frameworks include pytest and nose
# https://pytest.org
# https://nose.readthedocs.io
- run:
name: run tests
command: |
. venv/bin/activate
python manage.py test
- store_artifacts:
path: test-reports
destination: test-reports

6 changes: 6 additions & 0 deletions ci-notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
minikube for k8s 1.11, which is requires for kubeadm, which requires systemd, which requires ubutnu 16.04+

machine: true
priveliged: true
systemd: true

1 change: 1 addition & 0 deletions ci/.vagrant/machines/default/docker/vagrant_cwd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/home/erik/dev/z2jh-extended/z2jh/ci
1 change: 1 addition & 0 deletions ci/.vagrant/machines/default/virtualbox/action_provision
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.5:b9aaade0-5d14-4395-885c-a36771b7a698
1 change: 1 addition & 0 deletions ci/.vagrant/machines/default/virtualbox/action_set_name
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1533580135
1 change: 1 addition & 0 deletions ci/.vagrant/machines/default/virtualbox/creator_uid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1000
1 change: 1 addition & 0 deletions ci/.vagrant/machines/default/virtualbox/id
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
b9aaade0-5d14-4395-885c-a36771b7a698
1 change: 1 addition & 0 deletions ci/.vagrant/machines/default/virtualbox/index_uuid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1683168e9eaf4cb4943e8fc9876239a0
27 changes: 27 additions & 0 deletions ci/.vagrant/machines/default/virtualbox/private_key
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEAyyka4o3ipOV/IDsh/RiYAXYQ4k1UjeapJqaVsCrx5IzXaIXX
7TAc9hOuHm29pUh/1LZUXqY5IRKGggGI1q8hgQvNHnEyhmH23Ew7owYq9FDzi/Ap
JJ6S7aFA3bKmYkBTEu6EyV2PxVByC7EWTh6EIAGXCuh4OXb9li0AU/6JLwyIzt5q
GDf91oyZr6TX9W47GYHcDV/GgZoXH518Yu8texM6SSQBKDgFo+3WT9cPND7LGm5h
YWjhj7Pz4JKf0CUNFrOa9bdtScZQc5ggnzcynDKquke5KEDkJuOXRnAeyVO/USj6
ml6MMFjfc4P7GQzv8ffVbPJjSO6xAcAOIl6h+QIDAQABAoIBABFIOuBA36HVX/4W
6apFGFEvgPovR90WXRdLnnow/QjLLlvW3upvaFdKj0pJXZOc2jr3E7BFhaCZmdWf
WcuhdEEtBtLrIDgsRzqwRXZ1xNupsz4ZPPa/gpIyYHk7hEnhXO/EWIlkqyFG2ZzD
ALm+gNDUMcwcwHVq+OF4jImYooTc7jTdXJ99evCctvPuWk2CdnMKsnB4uLiDNqr/
w+PG3Ra/dNNrz38xNCqv64O9VhJeeYBi9+QwbYfANy5azTXYpclOWrfea88Gtxq5
kMBV5up5AuaGRz0HU/30fIsEsP9CLn1ZNCQGi3t/LWshqUd+zHaoHFC0btKNDXzS
XUnW2L0CgYEA9LMMaa+2byqkbmH8RRldnIx8fq4v3K6K2wr+ktlx6awb0fI3Exlr
N/ixe/Sf1Hqi3GZhmyXlQC6AE/tTOkTKMiR09MCQysURvPye9imtXKDG+TPk+vMd
I5K3qB435zE/eZ/i8b2aNPlb+I9cUYAcWvFw6l78YozyvCdg/1zbbGsCgYEA1Ir2
/XnnnbqSLqv2cSlEGMPLwoY2DsdaZXGt4xVe6xw5Or9RFWkXUFw0Zk+a4gXDnNXq
sIFjf/E3mODLVSrWzurkJCdqJqdN8MCkm0mQTIdLTaA65VzVdXzeWooEU+H0gfXM
mgCwtbb7BeshiU8ZFbFhuY/gz1Nuhfa11w/lRCsCgYAyVMGw21uC8hpwOedRry36
DUtuIxXlJmGZPGGwgtlTXvs568A4RXowQQ8AmAhoA/GLs+NPrjPBR89ATOmJiqys
M6N61EDz9CT54lwv9dKawtcqWuo2U9sifgMYqV6GRzLvKVvcrUsSqleogJRUjy1F
53N6QZ9YBfXHjbH91HOtkQKBgQC+tC1nQ+EpKgUN8We/I0qhedSypl+MpRyb1wMx
tLQk+n7zEkQ7lL7BcOnnPtf2oztf1qSsWHwhiRrchh6LPVPd9u5a7i6VnhoVwZQw
bTIXKHHNpc4SjFhPAYo07I9zgFM15Ij/SU1EznivV8kQfbNBPpYzvD/3ZqHNe46u
9+k7XwKBgQCicJf77CkB7yyh+59DoknFDqOKNX+Wvak05i0sOVQvACCsstUGkKrf
SldirdgH8kEnec77ZMHdDqlSzJRU5GvgEmpU8Lx0NmNA4wVxEeDU8JRdjhbYTlHW
kFgVodrsa34W4nnN23DOe+Fnylqk467uZnESWyAH+UQl6RRtU60UkQ==
-----END RSA PRIVATE KEY-----
1 change: 1 addition & 0 deletions ci/.vagrant/machines/default/virtualbox/synced_folders
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"virtualbox":{"/z2jh":{"guestpath":"/z2jh","hostpath":"/home/erik/dev/z2jh-extended/z2jh","disabled":false,"__vagrantfile":true},"/vagrant":{"guestpath":"/vagrant","hostpath":"/home/erik/dev/z2jh-extended/z2jh/ci","disabled":false,"__vagrantfile":true}}}
1 change: 1 addition & 0 deletions ci/.vagrant/machines/default/virtualbox/vagrant_cwd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/home/erik/dev/z2jh-extended/z2jh/ci
23 changes: 16 additions & 7 deletions ci/Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

# To test in vagrant:
# vagrant up
# vagrant ssh
# . ci/minikube.env
# /zero-to-jupyterhub-k8s/install.sh
# /zero-to-jupyterhub-k8s/test.sh
=begin
To test your setup...
vagrant up
vagrant ssh
cd /z2jh/ci
./install.sh
./test.sh
vagrant destroy
=end

Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/trusty64"
Expand All @@ -15,5 +22,7 @@ Vagrant.configure("2") do |config|
vb.cpus = 2
end
config.vm.provision "shell", path: "trusty-setup.sh"
config.vm.synced_folder "../", "/zero-to-jupyterhub-k8s"

# this makes changes
config.vm.synced_folder "../", "/z2jh"
end
28 changes: 28 additions & 0 deletions ci/bionic-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/sh

# Meant to be run from the Vagrantfile allowing

# Set shell options
# -e : Exit immediately if a command exits with a non-zero status.
# -u : Treat unset variables as an error when substituting.
# -x : Print commands and their arguments as they are executed.
set -eux

apt-get --quiet update
apt-get --quiet install --assume-yes socat

DOCKER_DEB=docker-ce_18.06.0~ce~3-0~ubuntu_amd64.deb
curl -sL --output $DOCKER_DEB https://download.docker.com/linux/ubuntu/dists/bionic/pool/stable/amd64/$DOCKER_DEB
# dpkg won't install dependencies
dpkg --install $DOCKER_DEB || sudo apt-get install --fix-broken --assume-yes
docker info

install --owner vagrant --group vagrant --directory /home/vagrant/bin

# Workaround Minikube DNS problems
# https://github.com/kubernetes/minikube/issues/2027#issuecomment-338221646
cat << EOF > /etc/resolv.conf
nameserver 8.8.4.4
nameserver 8.8.8.8
EOF
sed --in-place --regexp-extended --expression "s/^(127.0.0.1\\s.+)/\\1 `hostname`/" /etc/hosts
100 changes: 66 additions & 34 deletions ci/install.sh
Original file line number Diff line number Diff line change
@@ -1,63 +1,95 @@
#!/bin/bash
set -ex

mkdir -p bin
# Set shell options
# -e : Exit immediately if a command exits with a non-zero status.
# -u : Treat unset variables as an error when substituting.
# -x : Print commands and their arguments as they are executed.
set -eux

# install nsenter if missing (needed by kube on trusty)
# Install nsenter if missing (needed by kube on trusty)
if ! which nsenter; then
curl -L https://github.com/minrk/git-crypt-bin/releases/download/trusty/nsenter > nsenter
curl -sL --output nsenter https://github.com/minrk/git-crypt-bin/releases/download/trusty/nsenter
echo "5652bda3fbea6078896705130286b491b6b1885d7b13bda1dfc9bdfb08b49a2e nsenter" | shasum -a 256 -c -
chmod +x nsenter
sudo mv nsenter /usr/local/bin/
fi

# install kubectl, minikube
# based on https://blog.travis-ci.com/2017-10-26-running-kubernetes-on-travis-ci-with-minikube
echo "installing kubectl"
curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v${KUBE_VERSION}/bin/linux/amd64/kubectl
chmod +x kubectl
mv kubectl bin/
# Load environment variables
# --------------------------
source ./minikube.env

export KUBE_VERSION=1.11.0
export MINIKUBE_VERSION=0.28.2
export HELM_VERSION=2.9.1
export KUBEVAL_VERSION=0.7.1
export GIT_CRYPT_VERSION=0.5.0
export PATH="${PWD}/bin:$PATH"

export CHANGE_MINIKUBE_NONE_USER=true
export MINIKUBE_WANTUPDATENOTIFICATION=false
export MINIKUBE_WANTREPORTERRORPROMPT=false

# Download binaries
# -----------------
mkdir -p bin

echo "installing minikube"
curl -Lo minikube https://storage.googleapis.com/minikube/releases/v${MINIKUBE_VERSION}/minikube-linux-amd64
chmod +x minikube
mv minikube bin/
if ! [ -f bin/minikube-${MINIKUBE_VERSION} ]; then
curl -sL --output bin/minikube-${MINIKUBE_VERSION} https://storage.googleapis.com/minikube/releases/v${MINIKUBE_VERSION}/minikube-linux-amd64
chmod +x bin/minikube-${MINIKUBE_VERSION}
fi
cp bin/minikube-${MINIKUBE_VERSION} bin/minikube

echo "installing kubectl"
if ! [ -f bin/kubectl-${KUBE_VERSION} ]; then
curl -sL --output bin/kubectl-${KUBE_VERSION} https://storage.googleapis.com/kubernetes-release/release/v${KUBE_VERSION}/bin/linux/amd64/kubectl
chmod +x bin/kubectl-${KUBE_VERSION}
fi
cp bin/kubectl-${KUBE_VERSION} bin/kubectl

echo "installing helm"
if ! [ -f bin/helm-${HELM_VERSION} ]; then
curl -sL --output bin/helm-${HELM_VERSION}.tar.gz https://storage.googleapis.com/kubernetes-helm/helm-v${HELM_VERSION}-linux-amd64.tar.gz
tar --extract --file bin/helm-${HELM_VERSION}.tar.gz --directory bin --strip-components 1 linux-amd64/helm
rm bin/helm-${HELM_VERSION}.tar.gz
mv bin/helm bin/helm-${HELM_VERSION}
fi
cp bin/helm-${HELM_VERSION} bin/helm

echo "installing kubeval"
if ! [ -f bin/kubeval-${KUBEVAL_VERSION} ]; then
curl -sL --output bin/kubeval-${KUBEVAL_VERSION}.tar.gz https://github.com/garethr/kubeval/releases/download/${KUBEVAL_VERSION}/kubeval-linux-amd64.tar.gz
tar --extract --file bin/kubeval-${KUBEVAL_VERSION}.tar.gz --directory bin
rm bin/kubeval-${KUBEVAL_VERSION}.tar.gz
mv bin/kubeval bin/kubeval-${KUBEVAL_VERSION}
fi
cp bin/kubeval-${KUBEVAL_VERSION} bin/kubeval

# Setup Kubernetes
# ----------------
echo "starting minikube"
if [[ ${KUBE_VERSION} == 1.9* ]] || [[ ${KUBE_VERSION} == 1.10* ]]; then
BOOTSTRAPPER=localkube
sudo --preserve-env bin/minikube start --kubernetes-version=v${KUBE_VERSION} --vm-driver=none --bootstrapper=localkube --extra-config=apiserver.Authorization.Mode=RBAC
else
BOOTSTRAPPER=kubeadm
sudo --preserve-env bin/minikube start --kubernetes-version=v${KUBE_VERSION} --vm-driver=none --bootstrapper=kubeadm
fi
sudo CHANGE_MINIKUBE_NONE_USER=true $PWD/bin/minikube start --kubernetes-version=v${KUBE_VERSION} --vm-driver=none --bootstrapper=${BOOTSTRAPPER}
minikube update-context

echo "kubectl convenience details"
kubectl config set-context $(kubectl config current-context) --namespace jh
source <(kubectl completion bash)

echo "waiting for kubernetes"
JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'
until kubectl get nodes -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do
sleep 1
done
kubectl get nodes

echo "installing helm"
curl -ssL https://storage.googleapis.com/kubernetes-helm/helm-v${HELM_VERSION}-linux-amd64.tar.gz \
| tar -xz -C bin --strip-components 1 linux-amd64/helm
chmod +x bin/helm

kubectl --namespace kube-system create sa tiller
echo "initialize helm"
kubectl create serviceaccount tiller --namespace kube-system
kubectl create clusterrolebinding tiller --clusterrole cluster-admin --serviceaccount=kube-system:tiller
helm init --service-account tiller

echo "waiting for tiller"
kubectl --namespace=kube-system rollout status --watch deployment/tiller-deploy

echo "installing git-crypt"
curl -L https://github.com/minrk/git-crypt-bin/releases/download/0.5.0/git-crypt > bin/git-crypt
echo "46c288cc849c23a28239de3386c6050e5c7d7acd50b1d0248d86e6efff09c61b bin/git-crypt" | shasum -a 256 -c -
chmod +x bin/git-crypt

echo "installing kubeval"
curl -L https://github.com/garethr/kubeval/releases/download/0.7.1/kubeval-linux-amd64.tar.gz --output bin/kubeval.tar.gz
echo "8259d462bd19e5fc2db2ea304e51ed4db928be4343f6c9530f909dba66e15713 bin/kubeval.tar.gz" | shasum -a 256 -c -
tar xf bin/kubeval.tar.gz -C bin
chmod +x bin/kubeval
kubectl --namespace=kube-system rollout status --watch=true deployment/tiller-deploy
11 changes: 9 additions & 2 deletions ci/minikube.env
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
export MINIKUBE_VERSION=0.28.0
export KUBE_VERSION=1.10.0
export MINIKUBE_VERSION=0.28.2
export HELM_VERSION=2.9.1
export PATH="$PWD/bin:$PATH"
export KUBEVAL_VERSION=0.7.1
export GIT_CRYPT_VERSION=0.5.0
export PATH="${PWD}/bin:$PATH"

export CHANGE_MINIKUBE_NONE_USER=true
export MINIKUBE_WANTUPDATENOTIFICATION=false
export MINIKUBE_WANTREPORTERRORPROMPT=false
43 changes: 30 additions & 13 deletions ci/test.sh
Original file line number Diff line number Diff line change
@@ -1,37 +1,54 @@
#!/bin/sh

# SCRIPT SUMMARY
# --------------
# 1. Install the Helm chart using minikube-config.yaml
# 2. Wait for the hub to become responsive
# 3. Ensure a user can be created, spawned and culled using the hub's API
# http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyterhub/jupyterhub/master/docs/rest-api.yml

# Set shell options
# -e : Exit immediately if a command exits with a non-zero status.
# -u : Treat unset variables as an error when substituting.
# -x : Print commands and their arguments as they are executed.
set -eux

# Gather connection details
IP=$(ifconfig eth0 | grep 'inet addr' | cut -d: -f2 | awk '{print $1}')
TEST_NAMESPACE=jupyterhub-test
TEST_URL=http://$IP:31212
# Fetch network information
IP=$(ifconfig docker0 | grep 'inet ' | awk '{print $2}')
HUB_API_URL=http://$IP:31212/hub/api

# Install chart
helm upgrade jh \
--install \
--namespace $TEST_NAMESPACE \
--values minikube-config.yaml \
./jupyterhub/
--namespace jh \
--values ../minikube-config.yaml \
../jupyterhub/

echo "waiting for servers to become responsive"
until curl --fail --silent $TEST_URL/hub/api; do
kubectl --namespace=$TEST_NAMESPACE describe pod
until curl --fail --silent $HUB_API_URL; do
kubectl get pod --namespace jh --selector 'component in (hub,proxy,user-scheduler)'
kubectl describe pod --namespace jh --selector 'component in (hub,proxy,user-scheduler)'
sleep 10
done

http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyterhub/jupyterhub/master/docs/rest-api.yml#/
# Make various request using the hub's API
# -
echo "getting jupyterhub version and info"
curl --silent $TEST_URL/hub/api | grep version
curl --silent $TEST_URL | grep version

echo "getting jupyterhub info"
curl --silent $TEST_URL/hub/api/info
curl --silent $TEST_URL/info

echo "createing a user"
curl --silent --request POST --data ''
# TOOO

echo "spawning a user"
# TODO

echo "spaw user"
# FIXME:
# kubectl client v1.12 will have 'kubectl wait'
echo "waiting for test-user to spawn"
# TODO

echo "cull user"
Expand Down
Loading

0 comments on commit e968490

Please sign in to comment.