This tutorial is going to show how to setup your own kubernetes cluster (v.1.16.3 or latest) on ubuntu 18.04
Here i am installing kubernetes cluster on 3 servers
On all 3 servers
First, set up the Docker and Kubernetes repositories:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
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
Install Docker and Kubernetes packages:
Note that if you want to use a newer version of Kubernetes, change the version installed for kubelet, kubeadm, and kubectl. Make sure all three use the same version.
sudo apt-get update
sudo apt-get install -y docker-ce=18.09 kubelet kubeadm kubectl
sudo apt-mark hold docker-ce kubelet kubeadm kubectl
Enable iptables bridge call:
echo "net.bridge.bridge-nf-call-iptables=1" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
On the Kube master server
Initialize the cluster:
sudo kubeadm init --pod-network-cidr=10.244.0.0/16
Set up local kubeconfig:
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
Note: If you are using Kubernetes 1.16 or later, you will need to use a newer flannel installation yaml instead:
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/3f7d3e6c24f641e7ff557ebcea1136fdf4b1b6a1/Documentation/kube-flannel.yml
On each Kube node server
Join the node to the cluster:
sudo kubeadm join $controller_private_ip:6443 --token $token --discovery-token-ca-cert-hash $hash
On the Kube master server
Verify that all nodes are joined and ready:
kubectl get nodes
You should see all three servers with a status of Ready:
NAME STATUS ROLES AGE VERSION
ip-192-168-2-101 Ready master 54m v1.16.3
ip-192-168-2-102 Ready <none> 49m v1.16.3
ip-192-168-2-103 Ready <none> 49m v1.16.3