Last active
November 19, 2018 07:56
-
-
Save leigh-johnson/ae08ff6eea178ac0f3a2d2d600a3ddd0 to your computer and use it in GitHub Desktop.
Updated init scripts for kubeflow + microk8s
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "Downloading and installing go" | |
wget https://dl.google.com/go/go1.11.2.linux-amd64.tar.gz /home/multipass/go1.11.2.linux-amd64.tar.gz | |
tar -xvf go1.11.2.linux-amd64.tar.gz |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e # exit immediately on error | |
set -u # fail on undeclared variables | |
error() { | |
printf '\E[31m'; echo "$@"; printf '\E[0m' | |
} | |
reminder() { | |
printf '\E[32m'; echo "$@"; printf '\E[0m' | |
} | |
# Ensure we run as root .. | |
if [[ $EUID -ne 0 ]]; then | |
error "This script should run using sudo or as the root user" | |
exit 1 | |
fi | |
# VM and K8S steps | |
snap install microk8s --classic --beta | |
snap install kubectl --classic | |
echo "Waiting 15 seconds for kubernetes services.." | |
sleep 15 # wait for microk8s to come up properly | |
microk8s.enable dns dashboard | |
microk8s.enable storage | |
# This gets around an open issue with all-in-one installs | |
iptables -P FORWARD ACCEPT | |
## KSONNET | |
# Issue affecting prebuilt binaries <= 0.13.0 https://github.com/ksonnet/ksonnet/issues/883 | |
# wget https://github.com/ksonnet/ksonnet/releases/download/v0.13.0/ks_0.13.0_linux_amd64.tar.gz -O ksonnet.tar.gz | |
# mkdir -p ksonnet | |
# tar -xvf ksonnet.tar.gz -C ksonnet --strip-components=1 | |
# cp ksonnet/ks /usr/local/bin | |
# rm -fr ksonnet | |
# build from source for now | |
go get github.com/ksonnet/ksonnet | |
cd $GOPATH/src/github.com/ksonnet/ksonnet | |
make install | |
until [[ `kubectl get pods -n=kube-system | grep -o 'ContainerCreating' | wc -l` == 0 ]] ; do | |
echo "Checking kube-system status until all pods are running ("`kubectl get pods -n=kube-system | grep -o 'ContainerCreating' | wc -l`" not running)" | |
sleep 5 | |
done | |
# Remind the user of the next steps | |
echo "" | |
reminder "Before running install-kubeflow.sh, please 'export GITHUB_TOKEN=<your token>'" | |
echo "" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
error() { | |
printf '\E[31m'; echo "$@"; printf '\E[0m' | |
} | |
if [[ -z "${GITHUB_TOKEN}" ]]; then | |
error "The GITHUB_TOKEN environment variable isn't set." | |
error "Please visit https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/" | |
exit 1 | |
fi | |
set -e # exit immediately on error | |
set -u # fail on undeclared variables | |
# Create a namespace for kubeflow deployment | |
NAMESPACE=${NAMESPACE:-kubeflow} | |
kubectl create namespace ${NAMESPACE} | |
# Which version of Kubeflow to use | |
# For a list of releases refer to: | |
# https://github.com/kubeflow/kubeflow/releases | |
VERSION=${VERSION:-v0.1.3} | |
# Initialize a ksonnet app. Set the namespace for it's default environment. | |
APP_NAME=${APP_NAME:-my-kubeflow} | |
ks init ${APP_NAME} | |
cd ${APP_NAME} | |
ks env set default --namespace ${NAMESPACE} | |
# Install Kubeflow components | |
ks registry add kubeflow github.com/kubeflow/kubeflow/tree/${VERSION}/kubeflow | |
ks pkg install kubeflow/core@${VERSION} | |
ks pkg install kubeflow/tf-serving@${VERSION} | |
ks pkg install kubeflow/tf-job@${VERSION} | |
# Create templates for core components | |
ks generate kubeflow-core kubeflow-core | |
# If your cluster is running on Azure you will need to set the cloud parameter. | |
# If the cluster was created with AKS or ACS choose aks, it if was created | |
# with acs-engine, choose acsengine | |
# PLATFORM=<aks|acsengine> | |
# ks param set kubeflow-core cloud ${PLATFORM} | |
# Enable collection of anonymous usage metrics | |
# Skip this step if you don't want to enable collection. | |
ks param set kubeflow-core reportUsage true | |
ks param set kubeflow-core usageId $(uuidgen) | |
# For non-cloud use .. use NodePort (instead of ClusterIp) | |
ks param set kubeflow-core jupyterHubServiceType NodePort | |
# Deploy Kubeflow | |
ks apply default -c kubeflow-core | |
until [[ `kubectl get pods -n=kubeflow | grep -o 'ContainerCreating' | wc -l` == 0 ]] ; do | |
echo "Checking kubeflow status until all pods are running ("`kubectl get pods -n=kubeflow | grep -o 'ContainerCreating' | wc -l`" not running). Sleeping for 10 seconds." | |
sleep 10 | |
done | |
# Print port information | |
PORT=`kubectl get svc -n=kubeflow -o go-template='{{range .items}}{{if eq .metadata.name "tf-hub-lb"}}{{(index .spec.ports 0).nodePort}}{{"\n"}}{{end}}{{end}}'` | |
echo "" | |
echo "JupyterHub Port: ${PORT}" | |
echo "" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# cloud-init for kubeflow | |
package_update: true | |
package_upgrade: true | |
runcmd: | |
- mkdir /kubeflow | |
- wget https://gist.githubusercontent.com/leigh-johnson/ae08ff6eea178ac0f3a2d2d600a3ddd0/raw/50b9e42e31708a97f9e00cf15c309fe43cd1e8fe/install-kubeflow-pre-micro.sh -O /kubeflow/install-kubeflow-pre-micro.sh | |
- chmod a+x /kubeflow/install-kubeflow-pre-micro.sh | |
- wget https://gist.githubusercontent.com/leigh-johnson/ae08ff6eea178ac0f3a2d2d600a3ddd0/raw/9f226187e75f755249e7600fee0bf6150d01b484/install-kubeflow.sh -O /kubeflow/install-kubeflow.sh | |
- chmod a+x /kubeflow/install-kubeflow.sh | |
- printf "\n\nexport KUBECONFIG=/snap/microk8s/current/client.config\n\n" >> /home/multipass/.bashrc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment