Skip to main content


Kubernetes Must-Know Commands: A Comprehensive Guide

Big Data Network Abstract Concept


Welcome to the official blog on Kubernetes must-know commands! Subsequently, Kubernetes, a powerful container orchestration platform, automates the deployment, scaling, and management of containerized applications. Companies of all sizes widely use it to run their applications in production. However, every Kubernetes user should know and master a few essential commands to effectively manage your Kubernetes cluster and applications, though Kubernetes is a complex platform.

This blog post provides a comprehensive guide to the following important Kubernetes commands that you should know.

kubectl get:

This command enumerates resources on your Kubernetes cluster, such as nodes, pods, deployments, and services such as.

kubectl get nodes
kubectl get pods
kubectl get deployments
kubectl get services

kubectl describe:

To get detailed information about a specific resource on your Kubernetes cluster, run the kubectl describe command.

kubectl describe node <node-name>
kubectl describe pod <pod-name>
kubectl describe deployment <deployment-name>
kubectl describe service <service-name>

kubectl create:

This command creates new resources on your Kubernetes cluster, such as nodes, pods, deployments, and services.

kubectl create node <node-name>
kubectl create pod <pod-name>
kubectl create deployment <deployment-name>
kubectl create service <service-name>

kubectl debug:

This command creates a debugging session for a Kubernetes workload or node, overall, allow you to debug problems with them.

kubectl debug (POD | TYPE[[.VERSION].GROUP]/NAME) [ -- COMMAND [args...] ]

kubectl cp:

This command copies files and directories between a local machine and also a Kubernetes container, deploying files to a container or debugging problems with it. Additionally, this command is useful for transferring files between a local machine and a Kubernetes cluster.

kubectl cp <file-spec-src> <file-spec-dest>

kubectl config:

This command manages Kubeconfig files, which configure the Kubernetes client. Thus, it can be used to troubleshoot problems with the Kubernetes client or to change its configuration. Moreover, this command can also be used to create new Kubeconfig files or to delete existing ones.

kubectl config SubCommand
kubectl config current-context
kubectl config delete-cluster minikube

kubectl edit:

This command edits a Kubernetes resource on the server, updating its configuration. Furthermore, this command can be used to edit multiple resources at once or to edit a specific resource field.

kubectl edit (Resource/Name | -f FileName)

kubectl diff:

This command compares the current version of a Kubernetes resource with the version that would be applied if the resource were updated or created using a Kubernetes manifest file, showing the changes that would be made.

kubectl diff -f fileName

kubectl delete:

This command deletes resources from your Kubernetes cluster. However, use this command with caution, as deleting a resource can make it unavailable to your applications.

kubectl delete node <node-name>
kubectl delete pod <pod-name>
kubectl delete deployment <deployment-name>
kubectl delete service <service-name>

kubectl apply:

This command applies the changes from a Kubernetes manifest file to your cluster, deploying and updating applications on Kubernetes. To apply changes to multiple resources at once or to apply changes to a specific resource field, run the kubectl apply command.

kubectl apply -f <manifest-file.yaml>

kubectl port-forward:

This command forwards a port from your local machine to a port on a pod. Additionally, this command is useful for debugging and testing applications running on Kubernetes. Specifically, this command can forward a port to a specific pod or to all pods in a namespace.

kubectl port-forward <pod-name> <local-port>:<remote-port>

kubectl exec:

This command executes a command in a running pod. Though, it is useful for troubleshooting and managing applications running on Kubernetes. To execute a command in a single pod or to execute a command in all pods in a namespace, run the kubectl exec command.

kubectl exec <pod-name> -- <command>

kubectl logs:

This command views the logs of a running pod, which is useful for troubleshooting and monitoring applications running on Kubernetes. To view the logs of a single pod or to view the logs of all pods in a namespace, run the kubectl logs command.

kubectl logs <pod-name>

kubectl scale:

This command scales the number of replicas of a deployment, enabling you to scale your applications up or down based on demand. To scale a deployment to a specific number of replicas or to scale a deployment to a percentage of its current size, run the kubectl scale command.

kubectl scale deployment <deployment-name> --replicas=<number-of-replicas>

kubectl top:

This command views the resource usage of nodes and pods. Because this command identifies resource bottlenecks and optimizes your cluster. To view the resource usage of all nodes and pods in a cluster or to view the resource usage of specific nodes and pods, run the kubectl top command.

kubectl top nodes
kubectl top pods

kubectl annotate:

This command updates the metadata associated with a Kubernetes resource by adding or modifying key-value pairs. Annotations store information that is not essential to the resource’s operation; however, they may be useful for other tools or systems.

kubectl annotate [--overwrite] (-f FILENAME | TYPE NAME) KEY_1=VAL_1 ... KEY_N=VAL_N [--resource-version=version]

To update pod ‘foo’ with the annotation ‘description’ and the value ‘my frontend’, run the following command: kubectl annotate pods foo description=’my frontend’.


kubectl annotate pods foo description='my frontend'

kubectl api-resources:

This command lists all the Kubernetes API resources that the server supports. However, it can be useful for getting a sense of the capabilities of the Kubernetes platform and for debugging problems.

kubectl api-resources

Furthermore, some additional tips for using Kubernetes commands:

To use a Kubernetes command with help, manifest file, verbose output, or namespace, use the -h, -f, -v, or -n flag, respectively.


Overall, Kubernetes is a robust container orchestration platform that provides powerful capabilities for managing applications at scale. However, its complexity can be a barrier to entry for new users. Therefore, it is one of the best ways to overcome this challenge is to learn the essential Kubernetes commands. Eventually, this blog post has provided a comprehensive guide to the important Kubernetes commands that you need to know.

However, mastering these commands, you will be able to effectively manage your Kubernetes cluster and applications, gaining the ability to deploy, scale, and troubleshoot your applications with ease. In addition to the commands listed in this blog post, there are many other powerful Kubernetes commands available; you can learn more about these commands by visiting the official Kubernetes documentation. Finally, I hope this blog post has been helpful. If you have any questions, please do not hesitate to leave a comment below.


Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Kamal Hajari

Kamal Hajari is a Lead Technical Consultant at Perficient based in Nagpur. He is a WebSphere Commerce Developer with experience in utilizing latest HCL Commerce framework, including Java EE, Spring, and MVC framework. He is a forward-thinking and results-driven professional with more than 8 years of commanding diverse experience.

More from this Author

Follow Us