Kubernetes

How Kubectl Removes a Pod?

Kubernetes pods are the slightest component of a Kubernetes application and contain one or more containers. A pod can consist of many closely linked containers or a particular container. These containers are structured into pods to expand source distribution intelligence.

An application executing on the same physical or computer-generated machine in a non-cloud situation corresponds to a cloud application executing on the identical logical host. Storing multiple containers in a pod makes it easy to acquire and exchange data between containers. All containers in the pod have the same network namespace, so that they can discover and associate with each other through a local host. Pods are linked by using the IP address of another pod or by detecting the resources of another pod.

When launching a Kubernetes cluster, we want to remove a pod from one of the nodes. We must troubleshoot the node, upgrade, or shrink the cluster. It’s not difficult to remove a module from a node, but there are a few steps we need to follow to certify that the application is not disturbed. We don’t run containers. We utilize pods to run the applications. Pods are pools of containers that consist of a single worker node. Every module has a unique IP address and hostname. In this article we will show how to remove pods in Kubernetes.

Prerequisites:

To remove all Kubernetes pods, we need to check our operating system. This example utilizes the operating system Ubuntu 20.04. Then, we check all further Linux distributions, depending on our preferences. Furthermore, we make sure that Minikube is an important module for running Kubernetes services. To implement this article smoothly, the Minikube cluster has to be installed on the system.

Method to Remove the Pods:

Now, we see the technique of removing the pods. Consider the attached procedure to work efficiently.

Start Minikube:

For running the commands, we need to open the terminal of Ubuntu 20.04. First, we open the applications of Ubuntu 20.04. Then, we search for “terminal” in the search bar. By doing this, the terminal can efficiently start to work. The most important objective is to launch Minikube:

This process takes a little time, and it is not recommended to exit the terminal until the Minikube begins to work. We can also upgrade the Minikube cluster.

Check Active Nodes:

We start the Kubernetes cluster. To view the cluster nodes in a terminal within a Kubernetes environment, verify that we are associated with the Kubernetes cluster by running “kubectl get nodes”. We check the title of the node we want to delete with “kubectl get nodes” and verify that all Pods could be securely shut down without distinctive processes.

In this step, we need to check the eminence of the node. To do this, go with the following command:

We get the node name, status, role, age, and version by running the above command.

To construct a pod with an nginx image, execute the command “kubectl run nginx image = nginx restart = Never”. This command constructs a pod called nginx that runs on the nginx image. It also tells Kubernetes to build a pod instead of deploying the pod.

Press Enter to create the pod. Now, we observe the newly created pod in the terminal.

List All the Pods:

The most significant phase is to mention all the data about the pods that exist in the system. To list, we need to run the “kubectl get pods” command on the terminal:

The names, status, restarts, and ages of all pods are displayed by executing the above command.

At this moment, we run the “kubectl get pod” command to view the position of the pod.

After that, to see the complete pod configuration, we run the command “kubectl describe pod nginx” in the terminal. Scroll to the bottom of the terminal to get the actions that ocurred in the pod. Now that pod is in progress and built, the image has been effectively dragged and allocated to the node:

The commands display the name, namespace, priority, node, start time, labels, annotations, current status, and IPs of the pod. It also shows detailed data about the container, such as the container ID and image location, host port, and state.

Delete the Pod:

Now, we have to remove the only definite pods instead of removing all pods at once.

Deleting the pod is easy. To remove the created pod, we execute “kubectl delete pod nginx”. Check the title of the pod we need to remove before clicking Enter. By running this command, the pod “nginx” has been removed from the terminal:

We also remove the pods altogether by running another command. In this example, we remove the pod termed “nginx”. Though, we can remove the pods as needed.

Conclusion:

Pods indicate procedures within the application, and they are an important module for getting the concept of the Kubernetes item. In some cases, pods act as an unintended mode to accomplish the containers in Kubernetes. This article explained the idea of pods, and we also learned why it’s significant to delete them. In addition, we also described how to eliminate pods separately. Now, we hope you can easily remove the pods that we need from the system. Check out Linux Hint for more tips and information.

About the author

Kalsoom Bibi

Hello, I am a freelance writer and usually write for Linux and other technology related content