Creating Kubernetes Cluster with Master and Worker Nodes

This topic describes how to Creating Kubernetes Cluster with Master and Worker Nodes.

Procedure

  1. Login to the master node, run command Kubeadm init --pod-network-cidr=192.168.0.0/16. See the output for reference:
    • Copy the text starting with kubeadm highlighted in yellow from the output of Kubeadm init command.
    • To make kubectl work for your non-root user, run these commands, which are also part of the kubeadm init output.
      mkdir -p $HOME/.kube
      sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
      sudo chown $(id -u):$(id -g) $HOME/.kube/config
      
    • Alternatively, if you are the root user, you can run export KUBECONFIG=/etc/kubernetes/admin.conf.
    • Installing a POD network:
      • kubectl apply -f https://docs.projectcalico.org/v3.14/manifests/calico.yaml
  2. Join your worker nodes to the master nodes.
    • To add new nodes to your cluster, do the following for each machine:
      • SSH to the machine
      • Become root (e.g. sudo su -)
      • Run the command that was output by kubeadm init. For example: kubeadm join --token <token> <control-plane-host>:<control-plane-port> --discovery-token-ca-cert-hash sha256:<hash>