Cyber Deals - Get up to 65% off on CKA, CKAD, CKS, KCNA, KCSA exams and courses!

Adding new nodes to Kubespray Managed Kubernetes Cluster

Adding new nodes to Kubespray Managed Kubernetes Cluster

Kubespray is a combination of Ansible and Kubernetes and you can use Kubespray for deploying production ready Kubernetes clusters.

Read how to deploy a Kubernetes cluster using Kubespray .

You can manage full-lifecycle of Kubernetes clusters using Kubespray and in this demo we will see how to add new nodes to existing Kubernetes clusters.

(Photo by Albin Berlin from Pexels )

For the demo, we have a running kubernetes cluster with 1x master node and 2x worker nodes.

gini@greenmango kubespray % kubectl get nodes
NAME       STATUS   ROLES    AGE    VERSION
master-1   Ready    master   3h6m   v1.19.3
node-1     Ready    <none>   3h5m   v1.19.3
node-2     Ready    <none>   3h5m   v1.19.3

Subscribe to YouTube Channel

Step 1: Provision new Nodes

Create new nodes and make sure it is available from the machine where you have your Kubespray repository. Also configure password-less ssh key based access to new nodes.

Step 2: Update Inventory

Update inventory/mycluster/hosts.yaml with new nodes information. See below example where we have added node-3 information.

all:
  hosts:
    master-1:
      ansible_host: 192.168.50.11
      ip: 192.168.50.11
      access_ip: 192.168.50.11
    node-1:
      ansible_host: 192.168.50.21
      ip: 192.168.50.21
      access_ip: 192.168.50.21
    node-2:
      ansible_host: 192.168.50.22
      ip: 192.168.50.22
      access_ip: 192.168.50.22
    node-3:
      ansible_host: 192.168.50.23
      ip: 192.168.50.23
      access_ip: 192.168.50.23
  children:
    kube-master:
      hosts:
        master-1:
    kube-node:
      hosts:
        node-1:
        node-2:
        node-3:
    etcd:
      hosts:
        master-1:
    k8s-cluster:
      children:
        kube-master:
        kube-node:
    calico-rr:
      hosts: {}

Step 3: Run cluster.yml to add new node to cluster

gini@greenmango kubespray % ansible-playbook \
  -i inventory/mycluster/hosts.yaml \
  cluster.yml -u devops -b -l node-3

Wait for playbook to be completed.

Also Read : 10 Tips for CKA & CKAD Exams

Step 4: Verify newly added node in Kubernetes cluster

Let us see if the nodes the added to Kubernetes cluster.

gini@greenmango kubespray % kubectl get nodes
NAME       STATUS   ROLES    AGE    VERSION
master-1   Ready    master   4h9m   v1.19.3
node-1     Ready    <none>   4h8m   v1.19.3
node-2     Ready    <none>   4h8m   v1.19.3
node-3     Ready    <none>   82s    v1.19.3

Here you go, new node named node-3 is part the cluster and you can schedule workload on the same.

Learn how to deploy a Kubernetes Cluster using Kubespray.

Gineesh Madapparambath

Gineesh Madapparambath

Gineesh Madapparambath is the founder of techbeatly. He is the co-author of The Kubernetes Bible, Second Edition and the author of Ansible for Real Life Automation. He has worked as a Systems Engineer, Automation Specialist, and content author. His primary focus is on Ansible Automation, Containerisation (OpenShift & Kubernetes), and Infrastructure as Code (Terraform). (Read more: iamgini.com)


Disclaimer: Views expressed in articles are those of the respective authors and do not necessarily reflect the views of their employers or this site. While we aim for accuracy, please verify information before relying on it, and let us know if you spot an error.
Share:

Related Posts

Automation

Configure Projects with Global Network in OpenShift

We will have requirements, where customer need to configure multiple projects but they want pods inside those projects to communicate each other. …

How To Add Custom Modules In Ansible

How To Add Custom Modules In Ansible

Okay, we all know Ansible installation is coming with default modules and you don’t need to download or configure any additional modules for normal …

HashiCorp Certified Terraform Associate – Learning & Exam Tips

HashiCorp Certified Terraform Associate – Learning & Exam Tips

Introduction I started using Terraform somewhere in 2018, but very limited usage as I thought it is just another tool for provisioning infrastructure …

How to delete a pod with Terminating state in OpenShift or Kubernetes Cluster

How to delete a pod with Terminating state in OpenShift or Kubernetes Cluster

There might be situations where you have already deleted pods (or already removed dc aka deployment configuration) but pods are stuck in Terminating …

How to Increase Attachment File Size Limit in GitLab

How to Increase Attachment File Size Limit in GitLab

We know GitLab is one of the best and easy to use git server solutions available in the market now. And GitLab CE is available...

Ansible

Deploy Minikube Using Vagrant and Ansible on VirtualBox – Infrastructure as Code

Okay, you started learning kubernetes; maybe you are following some courses or documentations. Some of the courses are arranged with FREE labs where …