Deployment scaling and source of truth
One workload, two conflicting intentions
A Git-tracked catalog manifest may request two replicas while the live Deployment requests five. The controller responds to the live API specification, not to an arbitrary file on a laptop. A file becomes effective only through an authorized apply or another delivery system. All examples are offline teaching material. The image registry and versions are deliberately non-deployable placeholders. No cluster, image or kubeconfig is included. Commands are static illustrations for a separately approved disposable cluster with verified ./lab.kubeconfig, bytemind-lab context, book-lab namespace, permissions and reviewed pinned images. Never run these against an unknown context.
Read before changing the target
The live specification is the desired count for the controller; status records observations that may lag. When an authorized operator needs five replicas, the scale subresource can change the target without editing the Pod template. Scaling is not a new release.
kubectl --kubeconfig ./lab.kubeconfig --context bytemind-lab -n book-lab get deployment/catalog -o jsonpath='{.spec.replicas}'kubectl --kubeconfig ./lab.kubeconfig --context bytemind-lab -n book-lab scale deployment/catalog --current-replicas=2 --replicas=5The second line is a mutation, not a read. It requests five only if the current desired count is two at the precondition check. It does not check the ready count and does not lock out later writers. No command was executed.
Understand why a later apply changes the count
Assume ordinary client-side apply, an explicit replicas field and no other writer. If scale changes the live count from two to five, reapplying a manifest that still declares two sets the target back to two. The file itself was never modified by scale.
apiVersion: apps/v1kind: Deploymentmetadata: name: catalog namespace: book-labspec: replicas: 2 selector: matchLabels: app: catalog template: metadata: labels: app: catalog spec: containers: - name: catalog image: registry.example.invalid/learning/catalog:1 resources: requests: cpu: 50m memory: 32Mi limits: cpu: 100m memory: 64MiThis file describes two replicas. A later authorized apply can restore that value, even if an operator previously changed the live count. No actual apply is required for the exercise.
Choose a single scaling owner
For a fixed-capacity workload, update the reviewed configuration source and deliver it consistently. An emergency scale may be temporary; record the reason, intended duration and follow-up change. An autoscaler or GitOps reconciler can also write replica counts. When an HPA controls the count, coordinate field ownership and omit a competing fixed replica value through a reviewed migration; blindly removing a previously applied field can reset it temporarily. Server-side apply has separate ownership and conflict rules.
STEP SOURCE LIVE DESIREDInitial 2 2Scale 2 5Reapply source 2 2This sequence assumes no other controller modifies the count. In a continuously reconciled environment, a manual change can be reverted sooner.
Verify actual service health and cost
A larger desired count may increase resource demand. Pods can remain Pending if the cluster lacks capacity. Scaling to zero intentionally stops this workload from serving through its Pods. Do not equate five ready replicas with five times the throughput: shared dependencies and traffic distribution matter. For a live change, verify capacity, readiness, response behavior and rollback plan.
Practice: resolve drift
Read lab-fixtures/deployments/scaling-cases.json. Predict each desired count, including the rejected guarded operation. Explain who should own replicas for a fixed-size service and an autoscaled service. Next, Services will explain how clients reach changing sets of Pods.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Deployment scaling and source of truth — knowledge check
Apply the lesson concepts to original offline scenarios.
A manifest declares two replicas; a scale request changes live desired to five. What happens to the file?
Under ordinary client-side apply with replicas explicitly set to two, what target follows reapply after scaling to five?
What does --current-replicas=2 compare?
Why coordinate fixed replica values with an HPA?
After scaling to five, only three Pods are ready. What is a sensible next step?