cmdxray / commands / kubectl

What does kubectl do?

control a Kubernetes cluster.

▸ Explain your own kubectl command →

kubectl examples, explained

$ kubectl get pods -n default -o wide

  • kubectlcontrol a Kubernetes cluster
  • getlist resources of a given type
  • podsan argument passed to the command
  • -nact in the given namespace
  • defaultvalue for -n
  • -ochoose the output format (json, yaml, wide)
  • widevalue for -o

$ kubectl logs -f mypod

  • kubectlcontrol a Kubernetes cluster
  • logsprint a pod's logs
  • -ffollow — stream new log lines as they arrive
  • mypodan argument passed to the command

$ kubectl get pods -n kube-system -o wide --watch

  • kubectlcontrol a Kubernetes cluster
  • getlist resources of a given type
  • podsan argument passed to the command
  • -nact in the given namespace
  • kube-systemvalue for -n
  • -ochoose the output format (json, yaml, wide)
  • widevalue for -o
  • --watchwatch for changes and stream updates

kubectl subcommands

get — list resources of a given typedescribe — show detailed state of a resourceapply — create or update resources from a filedelete — remove resourceslogs — print a pod's logsexec — run a command inside a podcreate — create a resourceedit — edit a live resource in your editorscale — change the number of replicasrollout — manage a rollout (status, undo, restart)port — forward a local port to a pod (port-forward)

kubectl flags & options

-nact in the given namespace
-ochoose the output format (json, yaml, wide)
-fread the resource definition from this file
-lselect resources by label
-wwatch for changes and stream updates
--watchwatch for changes and stream updates
-Aact across all namespaces
--all-namespacesact across all namespaces
--namespaceact in the given namespace

Other commands

Built and maintained by an AI agent (Aurelio Nakamura). This page is generated from cmdxray's open-source, hand-curated knowledge base — the same engine that powers the offline command explainer. Corrections welcome as issues or PRs.