# How to Install Kubernetes Cluster ###### tags: `Kubernetes` ## Basic Setup ``` sudo apt update sudo apt upgrade -y ``` ## Turn off swap ``` sudo swapoff -a ``` ``` vim /etc/fstab #/swap.img none swap sw 0 0 ``` ``` reboot ``` ## set up ipvs `sudo vim /etc/modules-load.d/modules.conf` > add this: ``` ip_vs_sh ip_vs_wrr ip_vs_rr ip_vs nf_conntrack ``` ``` sudo reboot ```` ## Install Docker ``` sudo apt install apt-transport-https ca-certificates software-properties-common -y 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 update && sudo apt install docker-ce -y sudo pkill -SIGHUP dockerd sudo groupadd docker sudo usermod -aG docker $USER ``` ## config docker ``` sudo vim /etc/docker/daemon.json ``` > add this: ``` { "exec-opts":["native.cgroupdriver=systemd"], "log-driver": "json-file", "log-opts": { "max-size": "100m" } } ``` ``` sudo service docker restart ``` ## Install docker compose ``` sudo curl -L "https://github.com/docker/compose/releases/download/1.26.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/bin/docker-compose sudo chmod +x /usr/bin/docker-compose ``` ## Install K8S ``` curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add sudo apt-add-repository "deb http://apt.kubernetes.io/ kubernetes-xenial main" sudo apt-get install kubeadm kubelet kubectl -y ``` ## Init Master ``` sudo kubeadm init --apiserver-advertise-address=<IP> --pod-network-cidr=10.244.0.0/16 mkdir -p $HOME/.kube sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config sudo chown $(id -u):$(id -g) $HOME/.kube/config ``` ## Join Node > Copy the message from your master when init your master node. ``` sudo kubeadm join 192.168.1.122:6443 --token 7uoe87.ollkkhqjbylca8go \ --discovery-token-ca-cert-hash sha256:970a5280b98543c86e4c7f91d603fc9d4bc667cfe675d5de2e0081f910767ca4 ``` ## Deploy Flannel ``` wget https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml kubectl apply -f kube-flannel.yml ``` ## Reference ### Install > https://blog.51cto.com/wutengfei/2121202 ### flannel > https://zhang0peter.com/2020/01/30/k8s-install-and-use-and-fix-bug/#flannel-masternode
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up