kubectl

The command-line tool for talking to a Kubernetes cluster's API server: creating, reading, changing and deleting objects.

In more detail

Every kubectl command becomes one or more API requests made with the credentials in your kubeconfig. The general shape is kubectl, a verb such as get or apply, a type, and a name. It warns when its version is more than one minor release away from the server.

Examples

kubectl get pods
kubectl version
kubectl apply -f pod.json
kubectl label namespace payments pod-security.kubernetes.io/enforce=restricted
kubectl create role order-reader --verb=get --verb=list --resource=pods --dry-run=client -o yaml
The course uses kubectl create role with --dry-run=client -o yaml, so the tool prints the Role it would create as YAML without touching a cluster.

Related terms

Related guides

Taught in

References

Certification courses