01 — Workloads
MemorizeImperative one-liners
k run NAME --image img # a single pod k create deployment NAME --image img --replicas N k scale deployment/NAME --replicas N # instant, creates no revision k set image deployment/NAME CONTAINER=newimg k set resources deploy NAME --requests cpu=200m,memory=128Mi k set env deploy NAME --from configmap/CM k set serviceaccount deploy NAME SA_NAME # SA is positional k rollout status|history|undo|restart deployment/NAME
k set --help lists the whole family. These replace hand-editing for every field they cover.
You changed a ConfigMap. Do the pods see it?
| Consumed as | Propagates? | Action |
|---|---|---|
envFrom / configMapKeyRef | No | k rollout restart deploy X |
volume mount with subPath | No — the mount is a copy | k rollout restart deploy X |
| plain volume mount | Yes, kubelet syncs (~60s) | nothing |
- Proof a restart happened is a new ReplicaSet (
k get rs), not "successfully rolled out". k exec POD -- env | grep KEYproves nothing — a pod that merely started after the edit shows the new value too.
Fields no generator can set — hand-edit
spec:
minReadySeconds: 15 # Ready this long before counted available
revisionHistoryLimit: 3 # old ReplicaSets kept (default 10)
progressDeadlineSeconds: 45
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
Siblings of replicas: and template: — not inside template:.
A Service has no endpoints
k get svc,po --show-labels # selector vs pod labels k get endpoints SVC # <none> = the selector matches nothing
<none>means selector mismatch. Diff it character by character —app-ckaO1(letter O) againstapp-cka01(zero) is a real class of fault.- Endpoints populated but nothing works = wrong
targetPort. Endpoints are written aspodIP:targetPortwith no listener check. k expose pod X --name X --port 80copies the pod's own labels — the quick way to rebuild a broken selector.
QoS — who gets evicted first
| Class | Condition | Evicted |
|---|---|---|
| Guaranteed | requests == limits, CPU and memory, every container | last |
| Burstable | anything in between | middle |
| BestEffort | no requests, no limits anywhere | first |
Gotchas
runmakes a pod and takes no resource noun.k run pod catalogcreates a pod namedpodwithcatalogas its command, into CrashLoop.createneeds the noun;runnever does.- Container name = the image basename at create time, typos included (
--image ngnixgives containerngnix). Look it up beforeset image. describe deployrenders MinReadySeconds and the surge pair but notrevisionHistoryLimit— use-o yaml.scalecreates no revision, sorollout undowon't reverse it.--recordis gone. The annotation key must be exactlykubernetes.io/change-causeor it never shows inrollout history.
k explain deploy.spec.strategy is faster and version-exact.