FahamLah

Kubernetes commands

One page per command. What it does, when to use it, how risky it is.

Look around

  • kubectl getLists objects as a table: pods, deployments, services and more.Risk: Safe
  • kubectl describeTells the whole story of one object, with its events at the end.Risk: Safe
  • kubectl explainShows the built-in docs for a field.Risk: Safe
  • kubectl waitWaits until something becomes true.Risk: Safe
  • kubectl versionShows the kubectl and cluster versions.Risk: Safe

Change the cluster

Rollouts

Debug

  • kubectl logsShows what a container printed.Risk: Safe
  • kubectl execRuns one command inside a running container.Risk: Careful
  • kubectl port-forwardOpens a private tunnel from your laptop to one pod.Risk: Safe
  • kubectl debugAdds a temporary debug container to a pod, with your own tools.Risk: Careful
  • kubectl topShows CPU and memory in use now (needs metrics-server).Risk: Safe
  • kubectl eventsShows the manager's notice board: scheduled, pulled, started, and warnings.Risk: Safe

Where am I?

Nodes

  • kubectl cordonStops new pods going to a node. Pods already there stay.Risk: Careful
  • kubectl drainCordons a node and evicts its pods. emptyDir data is lost.Risk: Can lose work
  • kubectl taint nodesPuts a lock on a node. Only pods with the key (a toleration) may come.Risk: Careful

Packages and overlays

  • kubectl kustomizeBuilds YAML from a base plus an overlay (names, labels, images, replicas).Risk: Safe
  • helm templateFills a chart with values and prints the YAML. Installs nothing.Risk: Safe
  • helmInstalls a chart as a release, and later upgrades or rolls it back.Risk: Careful