Browse kubectl commands with flags, examples, and tips for Kubernetes cluster management.
get
List one or more resources.
describe
Show detailed information about a specific resource or group.
apply
Apply a configuration to a resource from a file or stdin.
delete
Delete resources by file, name, or label selector.
create
Create a resource from a file or from stdin.
edit
Edit a resource in the default editor (EDITOR env var).
logs
Print the logs for a container in a pod.
exec
Execute a command in a running container.
port-forward
Forward local port(s) to a pod, deployment, or service.
cp
Copy files and directories to and from containers.
rollout
Manage rollouts of deployments, daemonsets, and statefulsets.
scale
Scale a deployment, replicaset, or statefulset.
set image
Update the image of a container in a deployment.
autoscale
Auto-scale a deployment or replicaset based on CPU usage.
expose
Expose a resource as a new Kubernetes service.
get endpoints
List endpoints of services to verify traffic routing.
config get-contexts
Display all configured Kubernetes contexts.
config use-context
Switch the active Kubernetes context.
config set-context
Set a default namespace for the current context.
config view
Display the merged kubeconfig settings.
top
Display resource CPU and memory usage. Requires metrics-server.
get events
List cluster events, sorted by time by default.
debug
Create a debugging session for a pod or node.
get nodes
List all nodes in the cluster.
cordon
Mark a node as unschedulable (prevent new pods from being assigned).
drain
Safely evict all pods from a node for maintenance.
uncordon
Mark a node as schedulable again after maintenance.
kubectl get
Syntax
kubectl get <resource> [name] [flags]
Common Flags
-n, --namespace
-o, --output
-A, --all-namespaces
-l, --selector
--watch
Example
kubectl get pods -n kube-system kubectl get all -A kubectl get pod my-pod -o yaml