kubectl basics
Answer: kubectl is the Kubernetes command-line tool for talking to a cluster's control plane through the API. It reads cluster and credential settings from a kubeconfig file, by default ~/.kube/config or the KUBECONFIG variable.
Everyday commands
kubectl get pods -A
kubectl describe pod web-0
kubectl logs deploy/web -f
kubectl apply -f app.yaml
kubectl delete -f app.yaml
kubectl exec -it web-0 -- sh
kubectl port-forward svc/web 8080:80
Contexts
kubectl config get-contexts
kubectl config use-context staging
kubectl config set-context --current --namespace=dev
Productivity
source <(kubectl completion bash)
alias k=kubectl
complete -o default -F __start_kubectl k
Tips
--dry-run=client -o yamlto generate manifests.kubectl explain deployment.specfor field docs.
Claims
- id: C1 claim: Kubernetes provides a command line tool for communicating with a cluster. source: S1 evidence: "Kubernetes provides a command line tool for communicating with a Kubernetes cluster's"
- id: C2 claim: kubeconfig files organize cluster access. source: S1 evidence: "Organizing Cluster Access Using kubeconfig Files"
- id: C3 claim: kubectl completion sets up autocomplete in bash. source: S2 evidence: "source <(kubectl completion bash) # set up autocomplete in bash into the current shell"
- id: C4 claim: The quick reference covers kubectl logs. source: S2 evidence: "kubectl logs"
Sources
- [S1] Command line tool (kubectl). Kubernetes Authors. https://kubernetes.io/docs/reference/kubectl/ . License: CC BY 4.0 (kubernetes/website). Accessed 2026-11-04.
- [S2] kubectl Quick Reference. Kubernetes Authors. https://kubernetes.io/docs/reference/kubectl/quick-reference/ . License: CC BY 4.0 (kubernetes/website). Accessed 2026-11-04.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted).
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Kubernetes Authors, Command line tool (kubectl), CC BY 4.0 (kubernetes/website); Kubernetes Authors, kubectl Quick Reference, CC BY 4.0 (kubernetes/website).
Cite this
iinventedlight. 2026. "kubectl basics." iinventedlight Library, iil:note:1bcx1y08, version of 2026-11-04. https://iinventedlight.com/library/notes/kubernetes-kubectl-basics/. License: CC-BY-4.0.
@misc{iil_note_1bcx1y08,
author = {{iinventedlight}},
title = {{kubectl basics}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-04},
url = {https://iinventedlight.com/library/notes/kubernetes-kubectl-basics/},
note = {Permanent ID iil:note:1bcx1y08. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com.
For language models and agents: start at /llms.txt. This page in Markdown: /library/notes/kubernetes-kubectl-basics.md.