tectrack.net
  • Home
  • Cloud
    • AWS
    • Google Cloud
  • Virtualization
    • VMWare
  • Containers
    • Kubernetes
  • Other
No Result
View All Result
tectrack.net
  • Home
  • Cloud
    • AWS
    • Google Cloud
  • Virtualization
    • VMWare
  • Containers
    • Kubernetes
  • Other
No Result
View All Result
tectrack.net
No Result
View All Result

Kubernetes Nodes and Pods. Basic Commands You Must Know

Geeth Nuwan by Geeth Nuwan
July 10, 2023
in Kubernetes, Containers
Reading Time: 7 mins read
449 4
A A
0
Kubernetes Nodes and Pods. Basic Commands you must know

Kubernetes Nodes and Pods. Basic Commands you must know

Share on FacebookShare on TwitterShare on LinkedIn

Kubernetes is a powerful container orchestration platform that allows you to manage and deploy containerized applications. We all know that two of the most fundamental concepts in Kubernetes are Kubernetes Node and Pods. In this article, we are discussing about Kubernetes Nodes and Pods with the basic commands to work with them.

As assumptions for this article, we have to consider that our applications is already developed and built into Docker images. Also, we have to have Kubernetes cluster up and running. So now our goal is to deploy our application as a container on a set of machines which are configured as worker nodes in a cluster. Kubernetes does not directly deploy containers directly on the worker nodes. It encapsulates the application into a Kubernetes object known as a pod.

You might also like

Kubernetes Basic Concepts for Beginners

Kubernetes Basic Concepts, Beginner’s Walkthrough

July 10, 2023

Table of Contents

  • What is a Kubernetes Pod?
  • What is a Kubernetes Node?
  • How to create a new Kubernetes pod?
  • How to check pods and their Status in Kubernetes?
  • How to delete a Kubernetes pod
  • How to check all the details of a pod including events?
  • Use a pod-definition YAML file to create a new pod
  • How to change the image of a pod
  • How to check Kubernetes nodes status?

What is a Kubernetes Pod?

Simply we can say: A pod is the smallest object which you can create in Kubernetes. In another word, A pod is a single instance of an application. Pods are the basic building blocks of Kubernetes.

What is a Kubernetes Node?

Nodes are the worker machines that run containerized applications. When you deploy applications as Pods, it will be deployed on one or more nodes which is the actual machine your application is running on. A Pod always runs on a Node. A node can be a physical machine or a virtual machine. The control plane manages each node.

-
architecture of Kubernetes pod and node
Nodes and Pods – Two pods running in a single node.
(Image from: https://cloudplatform.googleblog.com/2015/01/what-makes-a-container-cluster.html)

How to create a new Kubernetes pod?

The following command will create a new Kubernetes pod, For example, let’s create a new pod with the nginx image. This will pull the nginx pod (application container) from the public repository

controlplane ~ ➜  kubectl run nginx --image=nginx
pod/redis created

How to check pods and their Status in Kubernetes?

When we create a pod, it will take a small amount of time to create the pod and start it. We can check the current status of the pods by the below commands. here we can find the pod name, status, age and a few other details.

controlplane ~ ➜  kubectl get pods
NAME            READY   STATUS              RESTARTS   AGE
nginx           1/1     Running             0          40s
newpods-dttrd   0/1     ContainerCreating   0          4s
newpods-jgrfb   0/1     ContainerCreating   0          4s
newpods-qhq6f   0/1     ContainerCreating   0          4s

controlplane ~ ➜  kubectl get pods
NAME            READY   STATUS    RESTARTS   AGE
nginx           1/1     Running   0          50s
newpods-dttrd   1/1     Running   0          14s
newpods-jgrfb   1/1     Running   0          14s
newpods-qhq6f   1/1     Running   0          14s

How to delete a Kubernetes pod

You can use the following command to delete a pod

kubectl delete pod <name>
controlplane ~ ➜  kubectl delete pod webapp
pod "webapp" deleted

How to check all the details of a pod including events?

We can use the below command to check all the details of pods, it will return large output including all the details of the pod.

kubectl describe pod    

describe a specific pod by name.

kubectl describe pod webapp

Use a pod-definition YAML file to create a new pod

01. We use kubectl run the command with –dry-run=client -o yaml the option to create a manifest file:

root@controlplane:~# kubectl run redis --image=redis123 --dry-run=client -o yaml > redis-definition.yaml

02. After that, use kubectl create -f command to create a resource from the manifest file:

root@controlplane:~# kubectl create -f redis-definition.yaml 
pod/redis created

03. Verify the work by running kubectl get command:

root@controlplane:~# kubectl get pods

How to change the image of a pod

We need to specify the container image that will be used for each container to deploy an application in a pod, This can be done via the Pod specification file, which is a YAML or JSON. It defines the desired state of the Pod. In the Pod specification, you can specify the name of the container image, the version, and other configuration parameters, such as environment variables, commands, and arguments. In case if we need to change this image in a pod, we can you below method.

Use the kubectl edit command to update the image of the pod to redis.

root@controlplane:~# kubectl edit pod redis

Above command will get you to the definition file where you can see the current config.

updating the image of a kubernetes pod

Make changes and save & exit with the Esc :wq command. If you used a pod definition file then update the image name in the definition file via Vi or Nano editor and then run kubectl apply command to update the image:

Editing the definition.yaml file using VI editor to update the image name
Editing the definition.yaml file using VI editor to update the image name

updating the image

root@controlplane:~# kubectl apply -f redis-definition.yaml 
pod/redis configured

How to check Kubernetes nodes status?

controlplane ~ kubectl get nodes
NAME           STATUS   ROLES                  AGE   VERSION
controlplane   Ready    control-plane,master   15m   v1.26.0+k3s1

retrieve more details on nodes

controlplane ~ kubectl get nodes -o wide
NAME           STATUS   ROLES                  AGE   VERSION        INTERNAL-IP   EXTERNAL-IP   OS-IMAGE             KERNEL-VERSION   CONTAINER-RUNTIME
controlplane   Ready    control-plane,master   13m   v1.26.0+k3s1   172.25.0.41   <none>        Alpine Linux v3.16   5.4.0-1102-gcp   containerd://1.6.12-k3s1

We hope you get a basic understanding of Kubernetes Nodes and Pods from this article.

Tags: k8snodepod
Share251Tweet157Pin61Share44
Geeth Nuwan

Geeth Nuwan

I am a Systems Engineer by profession. Also enthusiastic IT professional specializing in Virtualization, Cloud technologies and enterprise infrastructure.

Related Stories

Kubernetes Basic Concepts for Beginners

Kubernetes Basic Concepts, Beginner’s Walkthrough

by Geeth Nuwan
July 10, 2023
0

Kubernetes AKA K8s is becoming a trending topic when it comes to DevOps, Systems Engineering and Cloud Technologies these days....

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recommended

[Fixed] Raw Device Mapping (RDM) Missing from a Windows VM

[Fixed] Raw Device Mapping (RDM) Missing from a Windows VM

March 30, 2023
Kubernetes Nodes and Pods. Basic Commands you must know

Kubernetes Nodes and Pods. Basic Commands You Must Know

July 10, 2023

Popular Story

  • How to Fix ESXi “MetadataDownloadError Could not download from depot” Error during Upgrades/Patching.

    How to Fix “MetadataDownloadError Could not download from depot” Error when Upgrades/Patching VMWare ESXi.

    1441 shares
    Share 576 Tweet 360
  • How I Passed LFCS (Linux Foundation Certified System Administrator). 10 Tips and Tricks to Pass LFCS

    814 shares
    Share 324 Tweet 203
  • Cross vCenter VM Migration Using xVMotion Tool | Step by Step Guide

    719 shares
    Share 288 Tweet 180
  • How to Point Cloudflare Registered Domain Name to your Web Hosting / cPanel account

    638 shares
    Share 255 Tweet 160
  • List Portgroups and IP address of VMs using PowerCLI

    634 shares
    Share 254 Tweet 159

Expert insights from Virtualization to cloud-native technologies

Categories

  • Certifications
  • Containers
  • How To
  • Kubernetes
  • Linux
  • PowerCLI
  • Scripting
  • Storage
  • Virtualization
  • VMWare

Pages

  • About
  • Contact
  • Home
  • Privacy Policy

The views and comments expressed anywhere on this site are strictly mine and not the opinions and views of my employer. [more]
  • Sponsor
  • Terms and Conditions
  • Privacy Policy
  • Contact Us

© 2023 tectrack.net

No Result
View All Result
  • About
  • Contact
  • Become Sponsor
  • Privacy Policy
  • Disclaimer

© 2023 tectrack.net

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In
This website uses cookies. By continuing to use this website you are giving consent to cookies being used. Visit our Privacy and Cookie Policy.