Last active
March 9, 2019 14:29
-
-
Save zzh8829/bdd29c7000672f7e529a8d19f68772a8 to your computer and use it in GitHub Desktop.
Mini Kubernete cluster setup with kubeadm on any ubuntu machine
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
| ### | |
| # master setup on fresh ubuntu machine | |
| ### | |
| sudo su | |
| # real memory is too expensive | |
| sudo fallocate -l 2G /swapfile | |
| sudo chmod 600 /swapfile | |
| sudo mkswap /swapfile | |
| sudo swapon /swapfile | |
| sudo echo "/swapfile none swap sw 0 0" >> /etc/fstab | |
| # install stuff | |
| sudo apt-get update && apt-get install -y apt-transport-https | |
| sudo curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - | |
| sudo echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" > /etc/apt/sources.list.d/kubernetes.list | |
| sudo apt-get update && apt-get install -y docker.io kubelet kubeadm kubernetes-cni | |
| # get golang 1.8 | |
| wget https://storage.googleapis.com/golang/go1.8.linux-amd64.tar.gz | |
| sudo tar -zxvf go1.8.linux-amd64.tar.gz -C /usr/local/ | |
| echo 'export GOROOT=/usr/local/go' >> ~/.bashrc | |
| echo 'export GOPATH=$HOME/go' >> ~/.bashrc | |
| echo 'export PATH=$PATH:$GOROOT/bin:$GOPATH/bin' >> ~/.bashrc | |
| source ~/.bashrc | |
| # patch kubeadm because i am cheap | |
| go get -d k8s.io/kubernetes | |
| cd $GOPATH/src/k8s.io/kubernetes | |
| curl https://gist.githubusercontent.com/zzh8829/d5d53253310dee172dcc6091a7ea44c8/raw/e53a46ddb08b3338f39f6423bf2e4a640c8dd223/0001-Lower-Limits.patch > patch | |
| patch -p1 < patch | |
| # initilize master with flannel cni | |
| cd cmd/kubeadm | |
| go run kubeadm.go init --pod-network-cidr=10.244.0.0/16 | |
| ### | |
| # this part runs on your laptop | |
| ### | |
| scp root@"master ip":/etc/kubernetes/admin.conf ~/.kube/config | |
| kubectl get cluster-info | |
| kubectl taint nodes --all dedicated- | |
| # install flannel | |
| kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml | |
| # install dashboard | |
| kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/kubernetes-dashboard.yaml | |
| kubectl get pods --all-namespaces | |
| # check dashboard at localhost:8001/ui with | |
| kubectl proxy | |
| ### | |
| # this part runs on other worker machines | |
| ### | |
| sudo su | |
| # still can't afford memory :( | |
| sudo fallocate -l 2G /swapfile | |
| sudo chmod 600 /swapfile | |
| sudo mkswap /swapfile | |
| sudo swapon /swapfile | |
| sudo echo "/swapfile none swap sw 0 0" >> /etc/fstab | |
| # install stuff | |
| sudo apt-get update && apt-get install -y apt-transport-https | |
| sudo curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - | |
| sudo echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" > /etc/apt/sources.list.d/kubernetes.list | |
| sudo apt-get update && apt-get install -y docker.io kubelet kubeadm kubernetes-cni | |
| # your should get this line from the cmd output of master node | |
| kubeadm join --token="master token" "master ip" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment