Skip to content

Step 2: Setting up Kubernetes cluster

Rushikesh Pharate edited this page May 6, 2022 · 2 revisions

You should have 3 VM's [medium size(CPU: 6, Mem: 16 GB, Disk: 60 GB)] ready from this step apart from the one which is running Rancher.

Setting up master node

  1. Login to your Rancher dashboard. Click on Add Cluster at the top of the page.

  1. Select existing nodes.
  2. Give any Cluster Name of your choice and use Networking as Calico. Rest keep everything as default.

  1. Click Next.
  2. For the Node Role, select etcd, control plane and worker and click on advanced options. (Very Important)

  1. Enter the public IP address on any one VM and give a node name. You can ignore the field Node Internal address.

  2. Now, copy the command and run this command on the VM whose IP address you mentioned.

  3. After a minute you should get a message. Node registered. Wait for 5-10 mins. You should see the cluster to be in Active state.

Now, you master node is setup.

Setting up worker nodes

  1. Now, on the home screen click on three dots of the cluster you setup. Click on Edit.
  2. Go to the bottom. And now select worker as Node role and update the IP address of a different VM. This VM will act as a worker node.

  1. Copy the command again and run this on the VM (whose IP address we mentioned above).

Repeat the above steps for the third VM. Your final dashboard should look something like this.

Configuring Kubernetes on master node

  1. Copy the config files content mentioned in the above screenshot from the top right corner
  2. Login to master node and follow below steps
mkdir ~/.kube
vi ~/.kube/config

Paste the content of the Kubeconfig file and save it. 3) Run below commands

curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
curl -LO "https://dl.k8s.io/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl.sha256"
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
  1. After this, Kubernetes is set up on the master node and you can verify your cluster using below command
kubectl get nodes