[Kubernetes] Scaling ReplicaSets

1 minute read


Scaling ReplicaSets

  • K8s ReplicaSets CLI
  • Interpretation of the k8s ReplicaSets CLI

K8s ReplicaSets CLI

kubectl create deployment my-apache --image httpd

kubectl get all

# can be / or ' '(white space)
kubectl scale deploy/my-apache --replicas 2
# same as above
# deploy == deployment == deployments
kubectl scale deploy my-apache --replicas 2
kubectl scale deployment my-apache --replicas 2
kubectl scale deployments my-apache --replicas 2

Interpretation of the k8s ReplicaSets CLI

  • kubectl scale deploy my-apache --replicas 2
    • the end result should be 2 replicas
      • no matter the number of the current replica sets, the end result should be 2 replica sets
  • 1) the scale command changes the deployment configuration, the spec or the specification for the deployment
  • 2) the configuration manager sees the difference made
    • if only the replica count has changed(e.g. 1 -> 2), then it wouldn’t create a new ReplicaSet, it will simply change the number of ReplicaSets.
    • if some pod configuration(image name, tag, etc) has been changed then a new ReplicaSet would be created, and there would be two ReplicaSets running together for a period of time
  • 3) the scheduler inside of the control plane will see there’s a new pod, therefore will find a node that has available resources, schedule it for that node
  • 🔗 Pod diagram’s 4~7 will follow