Last active
January 13, 2020 18:42
-
-
Save longkai/e1f57d5612e86957e5b5c51f120c5a95 to your computer and use it in GitHub Desktop.
single node docker/Kubernetes setup script, enjoy!
This file contains 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
#!/bin/bash | |
sudo apt-get update | |
sudo apt-get install -y \ | |
vim \ | |
tmux \ | |
zsh \ | |
apt-transport-https \ | |
ca-certificates \ | |
curl \ | |
gnupg-agent \ | |
software-properties-common | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | |
sudo apt-key fingerprint 0EBFCD88 | |
sudo add-apt-repository \ | |
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \ | |
$(lsb_release -cs) \ | |
stable" | |
sudo apt-get update | |
sudo apt-get install -y docker-ce docker-ce-cli containerd.io | |
sudo docker run hello-world | |
# post install docker | |
sudo groupadd docker | |
sudo usermod -aG docker $USER | |
sudo systemctl enable docker | |
sudo curl -L https://github.com/docker/compose/releases/download/1.25.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose | |
sudo chmod +x /usr/local/bin/docker-compose |
This file contains 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
#!/bin/bash | |
./k8s-install-docker.sh # without root since it has root | |
sudo ./kubeadm.sh | |
mkdir -p $HOME/.kube | |
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config | |
sudo chown $(id -u):$(id -g) $HOME/.kube/config | |
# ref https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/ | |
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/2140ac876ef134e0ed5af15c65e414cf26827915/Documentation/kube-flannel.yml | |
kubectl taint nodes --all node-role.kubernetes.io/master- |
This file contains 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
#!/bin/bash | |
# ref https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/ | |
swapoff -a | |
cat > /etc/docker/daemon.json <<EOF | |
{ | |
"exec-opts": ["native.cgroupdriver=systemd"], | |
"log-driver": "json-file", | |
"log-opts": { | |
"max-size": "100m" | |
}, | |
"storage-driver": "overlay2" | |
} | |
EOF | |
mkdir -p /etc/systemd/system/docker.service.d | |
# Restart docker. | |
systemctl daemon-reload | |
systemctl restart docker | |
apt-get update && sudo apt-get install -y apt-transport-https curl | |
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - | |
cat <<EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list | |
deb https://apt.kubernetes.io/ kubernetes-xenial main | |
EOF | |
apt-get update | |
apt-get install -y kubelet kubeadm kubectl | |
apt-mark hold kubelet kubeadm kubectl | |
systemctl daemon-reload | |
systemctl restart kubelet | |
kubeadm init --apiserver-cert-extra-sans k8s.example.com \ | |
--pod-network-cidr=10.244.0.0/16 \ | |
--apiserver-bind-port=8443 \ | |
--ignore-preflight-errors=NumCPU |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Github gist file order is sucks....
Just download all files and run
./k8s-install.sh
.