Ansible / Automation / DevOps / Kubernetes
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.
[email protected] 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
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.
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: {}
cluster.yml
to add new node to cluster[email protected] 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
Let us see if the nodes the added to Kubernetes cluster.
[email protected] 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.
Disclaimer: The views expressed and the content shared are those of the author and do not reflect the views of the author’s employer or techbeatly platform.
Gineesh Madapparambath
Gineesh Madapparambath is the founder of techbeatly and he is the author of the book - ๐๐ป๐๐ถ๐ฏ๐น๐ฒ ๐ณ๐ผ๐ฟ ๐ฅ๐ฒ๐ฎ๐น-๐๐ถ๐ณ๐ฒ ๐๐๐๐ผ๐บ๐ฎ๐๐ถ๐ผ๐ป.
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).
(aka Gini Gangadharan - iamgini.com)
This site uses Akismet to reduce spam. Learn how your comment data is processed.2 Responses
Leave a Reply Cancel reply
[…] Adding new nodes to Kubespray Managed Kubernetes Cluster – November 27, 2020 […]
[…] Read how to add new nodes in Kubespray managed Kubernetes Cluster […]