This post will display:
What are Kubernetes nodes?
Kubernetes nodes are the core components of a Kubernetes cluster that run containerized applications using pods. Kubernetes cluster has two types of nodes master nodes (control plane) and slave nodes (worker nodes).
Master nodes make decisions for the cluster and manage the worker nodes. It is responsible for scheduling and deciding which node containers will be executed, exposing services and APIs, and communicating with slave nodes. In contrast, slave nodes perform all Kubernetes processing according to master node instructions. Its main function is to deploy containerized apps inside pods. It can execute multiple pods and each pod can execute and manage multiple containers:
To run a Kubernetes cluster, the user can use various components but the cluster can be executed inside virtual machines or in containers. To run a Kubernetes cluster and its nodes in containers, the user must install a container runtime such as Docker. To install and run Docker on Windows, follow our “How to Install Docker Desktop on Windows” article.
How to create a node in a minikube kubernetes cluster?
Minikube is a cluster implementation tool that quickly sets up and runs a Kubernetes cluster. To get Kubectl (Kubernetes CLI tool) and minikube tools on the system, follow the linked article.“How to get started with Kubernetes and kubectl”. To create a node in minikube, first run Docker on the system. After that, follow the steps given below.
Step 1: Start the Minikube Cluster
Launch PowerShell as administrator. After that, execute the Kubernetes cluster using “minikube start” Permission:
Step 2: Get Nodes
To access the nodes of a running minikube cluster, use “Kubectl get nodes” kubectl command:
Step 3: Create a new node in the minikube cluster
To add or create a new node to a minikube cluster, use “add minikube node“Command. Right here.”-PThe ” option is used to specify the minikube cluster profile or name to which the node will be added:
add minikube node -P minicube
Step 4: Verification
To confirm, access the Kubernetes nodes again:
Here, you can see that we have effectively created and added a new node to the Minikube Kubernetes cluster:
Step 5: Check the status of nodes
To check the status of minikube cluster nodes, use the command below:
Here, you can see that our new node is effectively running inside the minikube cluster:
Unfortunately, the Kubectl tool does not provide any direct commands to create a node in Kubernetes. However, the user can create a new node by accessing the configuration of an already running node. Then, the user can create a “yamlFile for creating a node and pasting and editing the configuration of an already running node. For proper performance, follow the instructions below.
Step 1: Edit an existing node
To access the configuration of a previously executed node, use “kubectl edit node <नोड-नाम>” Permission:
kubectl edit node minikube-m02
Step 2: Copy the node configuration
On executing the above command, the node yaml configuration will open in notepad or on any default selected editor. Squeeze “CTRL+ATo select all node configurations, then pressCTRL+C“To copy them:
Step 3: Create a new Yaml file
Next, create a yaml file named “node.ymlPaste the copied instructions into the file using ” and “CTRL+V, Remove unnecessary instructions as highlighted below:
Rename node, “delete”UIDKey, and change the IP address as this address is already occupied by the running node. Also, remove “ImaginationSection from configuration:
Step 4: Create a New Node
After that, click “Apply”node.ymlFile to create new node in minikube cluster manually using below command:
apply kubectl -F node.yml
Step 5: Verification
To verify, list the minikube cluster nodes again:
Here, you can see that the new node has been successfully added to the Minikube Kubernetes cluster:
KIND is another popular, open-source tool used to execute and operate Kubernetes clusters. It executes on each cluster node in a separate Docker container. It is used for local development and testing purposes on the same machine.
To create a node in a Kind Kubernetes cluster, first, start Docker on the system. After that, install the KIND tool on the system and start the Kubernetes cluster using the following instructions.
Step 1: Create a Type Directory
To install Kind Tool on the system, first of all, go to “C“via disk drive”CD” command. After that, create a new directory named “Kind” Using the “mkdir” Permission:
Here, the result below shows that the directory has been created successfully”C” To drive:
Step 2: Install Type
Execute the command below to install types from binary:
curl.exe -Take Kind-windows-amd64.exe https:,kind.sigs.k8s.io,deli,v0.20.0,kind-windows-amd64
Now, move the KIND binary executable file to the newly createdKinddirectory using the given command:
move-item .\kind-windows-amd64.exe c:\kind\kind.exe
Step 3: Set the path variable
To access the Kind Tool command from the terminal, the user must add its installation path to the environment variables. To permanently set the type PATH environment variable, use the command below:
setx path “%PATH%;C:\Type”
Step 4: Create Node Configuration File
Next, run a multi-node Kubernetes cluster. To do this, create a file named “node.config,
Add the following snippet to the file:
– Role: control-plane
– Role: Worker
– Role: Worker
The above instructions are explained as follows:
- ,Kind“Specifies the cluster.
- ,nodes“The key is used to set up nodes in the cluster.
- ,RoleUnder “Node” specifies the node type. Here, you can see that we have created one master (control-plane) node and two slave (worker) nodes.
Step 5: Create and run a multi-node cluster
Next, go to the directory where “node.config“File has been created:
Create a new multi-node cluster usingcreate type cluster“Command. Here,”-Name“Used to set the cluster name, and”-config“Used to access the cluster or node configuration file:
create type cluster –Name=Multinode –config=node.config
The above command will read the cluster configuration from “node.config” file and create the cluster accordingly:
Step 6: Get Nodes
Now, access the KIND cluster nodes using “Kubectl get nodes” Permission:
Here, you can see that we have successfully created a control plane and two worker nodes. All these nodes are executed in separate Docker containers:
Step 7: Modify the Node Config File
To create a new node in a Kind Kubernetes cluster, modify the node configuration file and add a new role as shown below:
Comment: Kind does not allow us to add or create a new node at runtime. In other words, it is not possible to add a new node to a running cluster. To add a new node, the user must delete the cluster, update “config” file, add the required number of nodes, and recreate the cluster.
Step 8: Delete Cluster
To remove a Kubernetes cluster, simply use “type delete cluster“along with node”-Name“Option to specify the name of the cluster that you need to delete:
type delete cluster –Name=Multinode
Step 9: Create a modified multinode cluster
Next, create the cluster again using the command below:
create type cluster –Name=Multinode –config=node.config
Step 10: Get Nodes
To confirm, access Kubernetes nodes using “Kubectl get nodes” Permission:
The output below indicates that we effectively added a new node and ran a multi-node type Kubernetes cluster:
K3D is another k3s (Rancher Lab) product and Kubernetes distribution that executes directly on Docker. It can easily create and operate single and multi-node Kubernetes clusters on Docker. It is mostly used for Kubernetes local development and deployment.
To install k3d on the system and start the cluster, go through the following steps.
Step 1: Install k3d
First of all, k3d can be easily installed on the system using Chocolatey Windows pre-installed package. To install k3d on Windows using Chocolatey, use the given command:
Step 2: Verification
To check if k3d is installed on the system, run “k3d-help” Permission:
The output shows that k3d is successfully installed on Windows:
Step 3: Create and run a multinode k3d Kubernetes cluster
Next, run the k3d multi-node Kubernetes cluster using “k3d cluster <क्लस्टर-नाम> create” Permission:
k3d cluster creates multinode –Agent 2 –Server 1
Here, “-Agent“Specify the number of worker nodes, and”-Server“Specify the number of master (control-plane) nodes.
Step 4: List the nodes
After creating the cluster, run “k3d node list” Permission:
Here, the output below shows that three cluster nodes are executing one is the server (master) node and the other two are agent (worker) nodes:
Step 5: Create a new node in the K3d cluster
K3D Cluster fortunately allowed us to create a new node while running the cluster. To create a new node in the K3D Kubernetes cluster, use “k3d node <नोड-नाम> <प्रकार> -cluster <क्लस्टर-नाम> create” Permission:
k3d node create demo-node –Role Representative –cluster multinode
Step 6: Verification
To check whether a new node has been added to the Kubernetes cluster, use the command below:
The output shows that the new node is effectively being added and executing to the multinode k3d Kubernetes cluster:
How to delete a node from a K3d Kubernetes cluster?
To remove a K3d cluster node, use “k3d delete node <नोड-नाम>” Permission:
k3d node delete k3d-demo-node-0
How to delete a node using kubectl tool?
To remove any Kubernetes node using kubectl tool, use “kubectl delete node <नोड-नाम>” Permission:
kubectl delete node minikube-m03
This is all about creating new nodes in a Kubernetes cluster.
Unfortunately there is no “kubectl create nodeCommand to create a node in Kubernetes. Each appliance running a Kubernetes cluster for local development has different procedures and commands for creating and starting a new node. In Minikube, use “add minikube node” command. In a Kubernetes cluster, add a new node using the configuration file, and every time the user needs to recreate the cluster. In K3D, create a new node using “k3d node <नोड-नाम> <प्रकार> create” Command. We have covered how to create nodes in a Kubernetes cluster.