Skip to content
Kubectl

icon picker
kubectl commands

kubectl get command
kubectl get <object_type> <object_name> -o <output> --sort-by <JSONpath> --selector <selector>
-o → set output format either yaml/json/wide
—sort-by → sort output using json path expression
—selector → filter results by label

kubectl describe command
To get detailed information about any k8s object
kubectl describe <object_type> <object_name>

kubectl create command
To create any k8s object
kubectl create -f <file_name>

kubectl apply command
It is similar to kubectl create command except if we use kubectl apply on already existing object, it will modify the existing object if possible but kubectl create command will fail if object already exists.
kubectl apply -f <file_name>

kubectl delete command
To delete any k8s object
kubectl delete <object_type> <object_name>

kubectl exec command
It is used to execute any command inside the running container
kubectl exec <pod_name> -c <container_name>

Getting resource usage data
kubectl top
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.