Three replicas were enough for the first day. The shop is busy now.
kubectl scale
text
learner@shallows:~$ kubectl scale deploy market-web --replicas=5
deployment.apps/market-web scaled
learner@shallows:~$ kubectl get rs
NAME DESIRED CURRENT READY AGE
market-web-7676f9f845 5 5 5 4mScaling changes one field, spec.replicas, and the current ReplicaSet follows. No new ReplicaSet appears, because the Pod template did not change. Scale down and Pods go to Terminating; the ReplicaSet stays.
scalespec.replicas
no new ReplicaSetsame ReplicaSet, Pod count changes
set imagespec.template
new ReplicaSetPods replaced, next lesson
Three ways to set replicas
| Way | When |
|---|---|
kubectl scale deploy NAME --replicas=N | Quick, by hand |
Change replicas: in the file, kubectl apply -f | When the Deployment has a file. The file is the record |
kubectl edit deploy NAME | Opens the live object in an editor; saving applies it |
Hand changes are drift. If the Deployment came from a file, the next apply puts replicas back to what the file says.