DEV Community

Cover image for Top 10 Kubernetes Commands
Hasan Elsherbiny
Hasan Elsherbiny

Posted on

Top 10 Kubernetes Commands

in our previous article we have discussed what is Kubernetes
in this article we will go through the most important commands you need to know when you are dealing with K8

Check version

Check the version of kubectl and the Kubernetes cluster.

kubectl version
Enter fullscreen mode Exit fullscreen mode

get pods

List all pods in the current namespace.

kubectl get pods
Enter fullscreen mode Exit fullscreen mode

get nodes

List all nodes in the cluster

kubectl get nodes
Enter fullscreen mode Exit fullscreen mode

get deployments

List all deployments in the current namespace.

kubectl get deployments
Enter fullscreen mode Exit fullscreen mode

describe pod

Get detailed information about a specific pod.

kubectl describe pod [pod_name]
Enter fullscreen mode Exit fullscreen mode

get logs

View the logs of a specific pod.

kubectl logs [pod_name]
Enter fullscreen mode Exit fullscreen mode

apply

Apply a configuration file to create or update a resource (e.g., pod, service, deployment).

kubectl apply -f [filename]
Enter fullscreen mode Exit fullscreen mode

Execute

Execute a command in a running pod.

kubectl exec -it [pod_name] -- [command]
Enter fullscreen mode Exit fullscreen mode

scale deployment

Scale the number of replicas for a deployment.

kubectl scale deployment [deployment_name] --replicas=[num_replicas]
Enter fullscreen mode Exit fullscreen mode

Delete resource

Delete a resource by specifying its type and name.

kubectl delete [resource_type] [resource_name]
Enter fullscreen mode Exit fullscreen mode

these are commands you need to get started but for sure you will need more commands

Top comments (2)

Collapse
 
aminiyehia1 profile image
Amini Yehia

thanks for this list

Collapse
 
hasanelsherbiny profile image
Hasan Elsherbiny

you welcome