How to Set Up a Kubernetes Multi Node Cluster: A Day 6 of 40 Days Kubernetes
In this blog, I will guide you through the process of setting up a multi-node Kubernetes cluster using Kind. Kind is a tool that allows you to run local Kubernetes clusters using Docker container nodes. This is a great way to learn and experiment with Kubernetes without having to set up a cloud-based cluster.
What is a cluster ?
A Kubernetes (K8s) cluster is a set of interconnected machines (nodes) that work together to deploy, manage, and scale containerized applications.
Installation
To locally install k8s , we’re using kind package manager .
Kind is a tool for running local Kubernetes clusters using Docker containers. It is primarily designed for development and testing purposes, allowing you to create and manage Kubernetes clusters on your local machine or in CI/CD pipelines .
To install kind we use the following command on macOS:
brew install kind
Creating a Cluster
Once Kind is installed, you can create a cluster using the following command:
kind create cluster --name my-cluster
This will create a cluster with three nodes.
Accessing the Cluster
To access the cluster, you will need to use the kubectl
command-line tool. You can configure kubectl
to use the Kind cluster by running the following command:
kubectl config use-context kind-my-cluster
Verifying the Cluster
To verify that the cluster is running, you can run the following command:
kubectl get nodes
To check the current context
kubectl config current-context
Creating a Multi-Node Cluster
Create a config.yaml
file defining the cluster structure
Config file contents:
three node (two workers) cluster config
kind: Cluster apiVersion:
kind.x-k8s.io/v1alpha4
nodes:
role: control-plane
role: worker
role: worker
Create the cluster using the config file:
kind create cluster --image kindest/node:v1.29.4@sha256:3abb816a5b1061fb15c6e9e60856ec40d56b7b52bcea5f5f1350bc6e2320b6f8 --name kind-cluster-2 --config config.yaml
To list all the context
kubectl config get-contexts
Conclusion
In this blog, I have shown you how to set up a multi-node Kubernetes cluster using Kind. This is a great way to learn and experiment with Kubernetes without having to set up a cloud-based cluster.
References
Video:
https://www.youtube.com/watch?v=RORhczcOrWs&list=PLl4APkPHzsUUOkOv3i62UidrLmSB8DcGC&index=9
Documentation:
https://kind.sigs.k8s.io/docs/user/quick-start/#installing-with-a-package-manager
Subscribe to my newsletter
Read articles from Rahul Vadakkiniyil directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by