Install Kubernetes Cluster on BareMetal

Tested On

OS: Ubuntu 18.04
Kubernetes Version: v1.15.3
Docker Version: 18.09.8


apt-get update
apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL | sudo apt-key add
add-apt-repository "deb [arch=amd64] $(lsb_release -cs) stable"
apt-get update
apt-get install docker-ce docker-ce-cli
  • Install kubelet kubeadm and kubectl
curl -s | sudo apt-key add -
echo "deb kubernetes-xenial main" > /etc/apt/sources.list.d/kubernetes.list
apt-get install -y kubelet kubeadm kubectl
  • Configure docker for kubernetes
cat > /etc/docker/daemon.json <<EOF
   "exec-opts": ["native.cgroupdriver=systemd"],
   "log-driver": "json-file",
   "log-opts": {
     "max-size": "100m"
   "storage-driver": "overlay2"
systemctl daemon-reload
systemctl restart docker
  • Disable swap for kubernetes
swapoff -a
sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab


  • Initialize kubernetes cluster (I have two network interfaces one for public and one for private so I use the apiserver-advertise-address with the private address)
kubeadm init --apiserver-advertise-address --apiserver-cert-extra-sans
  • Configure kubectl
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
chown $(id -u):$(id -g) $HOME/.kube/config
kubectl get pods --all-namespaces
  • Install weaveworks network plugin
kubectl apply -n kube-system -f "$(kubectl version | base64 | tr -d '\n')"
  • If you want to run containers on the muster than remove the master taint
kubectl taint nodes --all
  • Join worker servers to kubernetes clsuer
kubeadm join --apiserver-advertise-address --token xxxxxxxxxxx --discovery-token-ca-cert-hash sha256:asdjlkasjfljasfljsldjflsdj
  • If you have multiple network interface like me than you need to add the following routes on the worker servers
ip route add dev ens1(private_network_inteface)
kubectl get pods --all-namespaces - to check that all pods are running