Skip to content

Instantly share code, notes, and snippets.

@coolbrg
Forked from jjo/play-with-k8s.com-jjo-setup.sh
Created December 11, 2017 07:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coolbrg/f8d180349ad863ff21b9ed064f5a0b74 to your computer and use it in GitHub Desktop.
Save coolbrg/f8d180349ad863ff21b9ed064f5a0b74 to your computer and use it in GitHub Desktop.
#!/bin/bash -x
## Setup http://labs.play-with-k8s.com/ env ala' jjo
# YEAH I TRUST RUNNING STUFF DIRECTLY AS ROOT way ->
#
# bash -x <( curl -L bit.do/jjo-pwk-sh )
#
# https://gist.github.com/jjo/78f60702fbfa1cbec7dd865f67a3728a/edit
# http://bit.do/admin/edit/jjo-pwk-sh
#
# Initialize cluster and FIXUP some play-with-k8s annoyances
test -d /etc/kubernetes/pki || (
kubeadm init --apiserver-advertise-address $(hostname -i) | tee ~/kubeadm-init.log
kubectl apply -n kube-system -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 -w0)"
curl -L -s https://git.io/kube-dashboard | sed 's/targetPort: 9090/targetPort: 9090\n type: LoadBalancer/' | kubectl apply -f -
kubectl get deployment --namespace=kube-system kube-dns -oyaml|sed -r 's,(.*--server)=(/ip6.arpa/.*),&\n\1=8.8.8.8,'|kubectl apply -f -
)
# k8s comfy'ness
cd
yum -q -y install bash-completion git-core tmux vim wget sudo which > /dev/null
kubectl completion bash > /etc/bash_completion.d/kubectl.completion
source /etc/bash_completion.d/kubectl.completion
# helm
HELM_VERSION=2.7.2
curl -LO https://storage.googleapis.com/kubernetes-helm/helm-v${HELM_VERSION}-linux-amd64.tar.gz
tar -xvf helm-v${HELM_VERSION}-linux-amd64.tar.gz
mv linux-amd64/helm /usr/local/bin/
helm init
helm repo update
# dev tools and latest GO
GO_VERSION=1.9.2
yum -q -y install gcc gcc-go gcc-c++ make strace lsof > /dev/null
curl -LO https://storage.googleapis.com/golang/go${GO_VERSION}.linux-amd64.tar.gz
tar -C /usr/local -xzf go${GO_VERSION}.linux-amd64.tar.gz
ln -sf /usr/local/go/bin/go* /usr/local/bin/
# jjo'isms
git clone http://github.com/jjo/config; rsync -a config/ ~/ && rm -rf config/
git clone http://github.com/jjo/bin
# show kubeadm join ...
echo "* Join nodes with:"
grep -o "kubeadm.*join.*" ~/kubeadm-init.log
kubeadm join --token $(kubeadm token list |sed -n 2p|egrep -o '^\S+') $(sed -rn s,.*server:.*//,,p /etc/kubernetes/admin.conf)
# tmate ftW
wget -q https://github.com/tmate-io/tmate/releases/download/2.2.1/tmate-2.2.1-static-linux-amd64.tar.gz && tar zxf tmate-*.tar.gz && ln -sf $PWD/tmate-*/tmate /usr/local/bin
echo "* Connect to address about to be shown, then run : pkill -1 tmate"
# ssh keys needed by tmate to start:
ssh-keygen -t rsa -b 4096 -P "" -f "$HOME/.ssh/id_rsa"
(script -qfc tmate |egrep -o "ssh \S+tmate.io") &
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment