You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?
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: Safekubectl describeTells the whole story of one object, with its events at the end.Risk: Safekubectl explainShows the built-in docs for a field.Risk: Safekubectl waitWaits until something becomes true.Risk: Safekubectl versionShows the kubectl and cluster versions.Risk: Safe
Change the cluster
kubectl applyMakes the cluster match your YAML file. Creates or changes objects.Risk: Carefulkubectl createMakes one new object from flags, without a file.Risk: Carefulkubectl deleteRemoves objects. A deleted namespace takes everything inside with it.Risk: Can lose workkubectl scale deploymentChanges how many copies the order asks for.Risk: Carefulkubectl expose deploymentMakes a Service: one order number for all matching pods.Risk: Carefulkubectl runStarts one lone pod. Nothing replaces it if it goes.Risk: Carefulkubectl labelAdds or removes a label. Selectors pick objects by labels.Risk: Carefulkubectl create roleMakes a job card: which verbs on which things, in one zone.Risk: Carefulkubectl create rolebindingPins a job card to a person or bot, in one zone.Risk: Carefulkubectl autoscale deploymentMakes a HorizontalPodAutoscaler that changes replicas from CPU use.Risk: Carefulkubectl create configmapPins a note of settings on the wall: a ConfigMap.Risk: Safekubectl create secret genericPuts a password or token in a Secret. It is only base64, not locked.Risk: Carefulkubectl set resourcesChanges the requests and limits in the pod template. A rolling update starts.Risk: Carefulkubectl create jobRuns a CronJob's task once, right now, as a new Job.Risk: Careful
Rollouts
kubectl set imagePuts a new image in the pod template. A rolling update starts.Risk: Carefulkubectl rollout statusWaits and reports until the new version is fully out.Risk: Safekubectl rollout historyLists the revisions: one per version of the pod template.Risk: Safekubectl rollout undoGoes back to the previous pod template, with a rolling update.Risk: Carefulkubectl rollout restartReplaces every pod with a fresh one, a few at a time.Risk: Careful
Debug
kubectl logsShows what a container printed.Risk: Safekubectl execRuns one command inside a running container.Risk: Carefulkubectl port-forwardOpens a private tunnel from your laptop to one pod.Risk: Safekubectl debugAdds a temporary debug container to a pod, with your own tools.Risk: Carefulkubectl topShows CPU and memory in use now (needs metrics-server).Risk: Safekubectl eventsShows the manager's notice board: scheduled, pulled, started, and warnings.Risk: Safe
Where am I?
kubectl config get-contextsLists your clusters. A star marks where commands go.Risk: Safekubectl config use-contextSwitches to another cluster. Every later command goes there.Risk: Carefulkubectl config set-contextChanges the namespace your commands use by default.Risk: Carefulkubectl auth can-iAsks RBAC: may this user do this? Answers yes or no.Risk: Safekubectl auth whoamiShows who gate 1 thinks you are: your user name and groups.Risk: Safekubectl config current-contextPrints the one context your commands go to right now.Risk: Safekubectl cluster-infoShows the address of the control plane (the API server) and CoreDNS.Risk: Safekind create clusterOpens a practice cluster on your laptop. Each node is a Docker container.Risk: Safekind delete clusterDeletes a kind cluster and everything in it.Risk: Can lose work
Nodes
kubectl cordonStops new pods going to a node. Pods already there stay.Risk: Carefulkubectl drainCordons a node and evicts its pods. emptyDir data is lost.Risk: Can lose workkubectl 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: Safehelm templateFills a chart with values and prints the YAML. Installs nothing.Risk: SafehelmInstalls a chart as a release, and later upgrades or rolls it back.Risk: Careful