Installing Kubernetes on Bare Metal Server or Virtual machine via kubeadm

Kubernetes is docker orchestration tool developed by google.

For Installing kubernetes we required 4 packages to be installed on machine.

Install Docker for Ubuntu:

$ apt-get update

$ apt-get install -y

Install Docker for CentOS/RHEL:

$ yum install -y docker

$ systemctl enable docker && systemctl start docker

Install kubeadm, kubelet and kubectl.

kubeadm: The command to bootstrap the cluster.

kubelet: The component that runs on all of the machines in your cluster and does things like starting pods and containers.

kubectl: The command line util to talk to your cluster.

Install kubelet kubeadm kubectl kubernetes-cni for Ubuntu:

$ apt-get update && apt-get install -y apt-transport-https

$ curl -s | apt-key add -

$ cat <<EOF >/etc/apt/sources.list.d/kubernetes.list

deb kubernetes-xenial main


$ apt-get update

$ apt-get install -y kubelet kubeadm kubectl kubernetes-cni

Install kubelet kubeadm kubectl kubernetes-cni for CentOS/RHEL:

$ cat <<EOF > /etc/yum.repos.d/kubernetes.repo









$ setenforce 0

$ yum install -y kubelet kubeadm kubectl

$ systemctl enable kubelet && systemctl start kubelet

Initializing cluster with kubeadm

On master node

$ kubeadm init — pod-network-cidr= — apiserver-advertise-address=

— apiserver-advertise-address determines which IP address Kubernetes should advertise its API server on.

You will get this when you done with Kubadm init.

Your Kubernetes master has initialized successfully!

To start using your cluster, you need to run (as a regular user):

$ mkdir -p $HOME/.kube

$ sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config

$ sudo chown $(id -u):$(id -g) $HOME/.kube/config

You should now deploy a pod network to the cluster.

Run “kubectl apply -f [podnetwork].yaml” with one of the options listed at:

You can now join any number of machines by running the following on each node

as root:

$ kubeadm join — token 7ed3b7.ae447f51edc87df2 — discovery-token-ca-cert-hash sha256:7b19036bd9cfc7e4e09721448e0a0467cf7fc67c982abbf36f478e0c2eec32cb

Via this token you can connect new nodes to master.

For installing nodes you need to do all the steps as given above but only $kubeadm init not required.

$kubectl apply — filename

For running kube-dns POD’s

Now you can check nodes for kubernetes cluster

$ kubectl get nodes

For checking which pods are running on kubernetes cluster

$ kubectl get pods — all-namespaces -o wide

Kubernets cluster running..!!!!

Like what you read? Give Sachin Arote a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.