Kubernetes: Deploy, roll out, roll back, scale
7 Kubernetes commands: Deploy, roll out, roll back, scale. Click a command to see what each part does.
Kubernetes: Deploy, roll out, roll back, scaleIndex
- Whole sheet137
- Basics: cluster, namespaces & resources17
- Get & list resources23
- Context & namespace3
- Find resources9
- Debug: describe, events, logs8
- Exec, port-forward, copy4
- Deploy, roll out, roll back, scale7
- Cleanup & nodes4
- Services, DNS & networking checks6
- Environment, config & secrets of workloads9
- Create, generate & apply YAML10
- Patch, label, annotate & scale9
- Delete & force delete6
- Nodes, scheduling & access control11
- Productivity: aliases, contexts & output11
Deploy, roll out, roll back, scale7
kubectl diff -f <dir> && kubectl apply -f <dir>Preview then apply manifestsWhat each part does
diff -f <dir>show what would change on the server&&continue only if diff ran without error (diff exits 1 when there are changes; use ; instead if you want to apply anyway)apply -f <dir>create or update every manifest in the folder
kubectl set image deployment/<deployment> <container>=<image>:<tag> -n <namespace>Change the image of a deploymentCautionWhat each part does
set imageupdate container images → triggers a rolling updatedeployment/<deployment>which deployment<container>=<image>:<tag>container name in the pod spec = new image
kubectl rollout status deployment/<deployment> --timeout=5mWait for the rollout to finishWhat each part does
rollout statuswatch progress until done or failed--timeout=5mgive up (non-zero exit) after 5 minutes: good for CI
kubectl rollout history deployment/<deployment>; kubectl rollout undo deployment/<deployment> --to-revision=<n>History and rollbackCautionWhat each part does
rollout historylist revisionsrollout undogo back to the previous revision--to-revision=<n>or to a specific revision from the history
kubectl rollout restart deployment/<deployment> -n <namespace>Restart all pods of a deploymentCautionWhat each part does
rollout restartrolling restart without changing the spec (picks up new ConfigMap/Secret values)
kubectl scale deployment/<deployment> --replicas=<n>Scale replicasCautionWhat each part does
scaleset the desired replica count--replicas=<n>new count (0 stops the app)
kubectl create deployment <name> --image=<image> --dry-run=client -o yaml > deploy.yamlGenerate a manifest without creating anythingWhat each part does
create deploymentbuild a Deployment object--dry-run=clientdon't send it to the cluster-o yamlprint it as YAML> deploy.yamlsave to a file to edit and commit
Nothing matches.
My DevOps Playbook by Angelo John Calleja