Steps To Run A POD In A Selected Node In The Kubernetes

Steps to run a POD in Node

If you’re working with the Kubernetes cluster, you know how crucial it is to manage your PODs effectively. Running a POD in a selected node can help optimize your resources and improve performance. In this blog, we will show you the steps to run a POD in a Selected Node in the kubernetes environment.

Requirements

  • 2 Node Cluster ( 1 Master VM with 2 Nodes)
  • Kubernetes Components

Infrastructure Overview

  • To begin with, we need to install and configure the 2-node cluster in our environment. We had already installed and configured the 2 Node cluster in our demo environment. To learn more check our blog post.

Adding Label to the Node using Kubectl

  • Log in to the master server through putty.
Steps to run a POD in a Selected Node in the Kubernetes
  • Use show labels option to view the node’s labels.

kubectl get nodes --show-labels

Steps to run a POD in a Selected Node in the Kubernetes
  • Use the label command to set a label for a node.

Syntax: kubectl label <object type> <object name> <label values>

Example: kubectl lable node k8s-node2 type=hdd

Steps to run a POD in a Selected Node in the Kubernetes
  • Command executed successfully.
Steps to run a POD in a Selected Node in the Kubernetes
  • We can verify the label information using show labels option.
Steps to run a POD in a Selected Node in the Kubernetes

Creating a POD in NODE

  • Create a new file and paste the below coding.
Steps to run a POD in a Selected Node in the Kubernetes

apiVersion: v1
kind: Pod
metadata:
   name: node-pod
   labels:
      app: web
      env: test
spec:
   nodeSelector:
      type: "hdd"
   containers:
      - name: node-cont
        image: nginx

Steps to run a POD in a Selected Node in the Kubernetes
  • Save and close the file.
  • Create a new POD using the YAML file.
Steps to run a POD in a Selected Node in the Kubernetes
  • Command executed successfully.
Steps to run a POD in a Selected Node in the Kubernetes
  • Verify the pod status using wide option. We can see our new POD is assigned to node2 using the node labels.
Steps to run a POD in a Selected Node in the Kubernetes

Deleting a Label from NODE

  • Use the below command to delete a label from a node.

Syntax: kubectl label <object type> <object name> <label value>-

Example: kubectl label node k8s-node2 type-

Steps to run a POD in a Selected Node in the Kubernetes
  • Command executed successfully.
Steps to run a POD in a Selected Node in the Kubernetes
  • Verify the changes.
Steps to run a POD in a Selected Node in the Kubernetes

Video Tutorial

Thank you for taking the time to read our blog on “Steps To Run A POD In A Selected Node In The Kubernetes”. We hope you found the information valuable and insightful. If you find any issues with the information provided in this blog don’t hesitate to contact us (info@assistanz.com).

View Post>>

View Post>>