Skip to main content

Module deployment

Module deployment 

Source
Expand description

DeploymentController — reconciles Deployments into ReplicaSets.

K8s rule:

  • each Deployment owns 1..N ReplicaSets via ownerReferences
  • the CURRENT ReplicaSet is the one whose spec.template EQUALS the Deployment’s, ignoring the pod-template-hash label (upstream’s EqualIgnoreHash, see crate::pod_template) — the hash only names a new one
  • older ReplicaSets are kept around at replicas=0 so kubectl rollout undo still works (revision history)

R9.5 implementation (this file):

  1. For each Deployment, normalize its template.
  2. Find owned ReplicaSets (via uid).
  3. Pick the current one: an owned RS running an equal template (current_replicaset). If there is none, create one, named by the template’s hash.
  4. Scale the current RS to Deployment.spec.replicas.
  5. Scale every other owned RS to 0 (revision history retained).

Skips: status updates, paused rollouts, partial-rollout strategies — those are R9.5b. The substrate’s good enough to prove the controller pattern compounds.

Structs§

DeploymentController

Functions§

current_replicaset
The owned ReplicaSet that is a Deployment’s current one — upstream’s FindNewReplicaSet: an RS whose spec.template equals template, ignoring the pod-template-hash label. None when no owned RS runs it, the one case in which a new RS is created.