OS used Ubuntu 18.04 LTS

This is 3 node cluster setup implementations with the following sub-services
Kube Master – Docker, Kubeadm, Kubelet, kubectl, Control Plane
Kube node 1 – Docker, Kubeadm, Kubelet, kubectl
Kube node 2 – Docker, Kubeadm, Kubelet, kubectl
Docker is the container runtime that we will be using. The first step in building out the cluster is to install docker on all three servers.
Add the Docker repository GPG key :
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add –
Add the Docker repository :
sudo add-apt-repository \ "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) \ stable"
Reload the apt source list :
sudo apt-get update
Install Docker :
sudo apt-get install -y docker-ce=18.06.1~ce~3-0~ubuntu
Prevent auto-updates for the docker packages :
sudo apt-mark hold docker-ce
You can verify that docker is working by running this command:
sudo docker version
Install Kubeadm, kubelet and kubectl
Kubeadm – This is a tool that automate a large portion of the process of setting up a cluster. It will make our job much easier.
Kubelet – the essential running containers on a node. Every server that will be running containers needs kubelet.
Kubectl – command-line tool for interface with cluster once it is up. This used to manage the cluster.
Install kubeadm, kubelet and kubectl on all three servers :
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add –
Adding Kubernetes repositories :
cat << EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list deb https://apt.kubernetes.io/ kubernetes-xenial main EOF
Reload the apt source list :
sudo apt-get update
Install packages :
sudo apt-get install -y kubelet=1.15.7-00 kubeadm=1.15.7-00 kubectl=1.15.7-00
sudo apt-mark hold kubelet kubeadm kubectl
After installing these components, verify that Kubeadm is working by getting the version info :
kubeadm version
Bootstrapping the cluster
Use kubeadm to build the cluster
Initialized the cluster on the Kube Master server
sudo kubeadm init --pod-network-cidr=10.244.0.0/16
pod network cidr required later for the flannel networking plugin
setup kubeconfig for the local user on the Kube Master Server
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
Verify that the cluster is responsive and that Kubectl is working
kubectl version
Kubeadm init command should output a kubeadm join command containing a token and hash. Copy that command and run it with sudo on both worker nodes. It should look something like this
sudo kubeadm join $some_ip:6443 --token $some_token --discovery-token-ca-cert-hash $some_hash
Verify that all nodes have successfully joined the cluster :
kubectl get nodes
Configure networking with Flannel
Kubernetes supports a variety of networking solutions to provide networking between containers
On all three nodes, run the following:
echo "net.bridge.bridge-nf-call-iptables=1" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
Install Flannel in the cluster by running this only on the Master node:
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/bc79dd1505b0c8681ece4de4c0d86c5cd2643275/Documentation/kube-flannel.yml
Verify that all the nodes now have a STATUS of Ready :
kubectl get nodes
Note: It may take a few moments for all nodes to enter the Ready status, so if they are not all Ready , wait a few moments and try again