DEV Community

Cover image for 10 essential kubectl commands every dev should know
Aleson França
Aleson França

Posted on

10 essential kubectl commands every dev should know

If you’re working with Kubernetes, learning kubectl is a must.
Here are 10 practical commands to help you manage your cluster more easily


kubectl get pods

Show all pods in the current namespace.

kubectl get pods 
Enter fullscreen mode Exit fullscreen mode

kubectl get all

Returns all resources: pods, services, deployments, and more.

kubectl get all 
Enter fullscreen mode Exit fullscreen mode

kubectl logs

Check the logs of your application inside a pod.

kubectl logs my-pod 
Enter fullscreen mode Exit fullscreen mode

kubectl describe pod

See full details about a pod — useful for debugging.

kubectl describe pod my-pod 
Enter fullscreen mode Exit fullscreen mode

kubectl exec -it -- bash

Access the pod with a terminal session.

kubectl exec -it my-pod -- bash 
Enter fullscreen mode Exit fullscreen mode

kubectl delete pod

Delete a pod (if it’s part of a deployment, it will restart automatically).

kubectl delete pod my-pod 
Enter fullscreen mode Exit fullscreen mode

kubectl apply -f file.yaml

Create or update resources using a YAML file.

kubectl apply -f deployment.yaml 
Enter fullscreen mode Exit fullscreen mode

kubectl get services

List all services with their IPs and ports.

kubectl get svc 
Enter fullscreen mode Exit fullscreen mode

kubectl get nodes

Show all nodes in your Kubernetes cluster.

kubectl get nodes 
Enter fullscreen mode Exit fullscreen mode

kubectl config use-context

Switch between clusters or environments.

kubectl config use-context minikube 
Enter fullscreen mode Exit fullscreen mode

Bonus tip: Use kubectl explain <resource> to explore any resource directly in your terminal.

Top comments (0)