pub fn build_pod_labels_from_instance(
instance_name: &str,
instance: &Bind9Instance,
) -> BTreeMap<String, String>Expand description
Builds the label set stamped onto the Pods of a Bind9Instance.
This is deliberately a superset of build_labels_from_instance, which
remains the Deployment’s spec.selector and the Service’s selector.
§Why the two are separate
spec.selector on a Deployment is immutable — Kubernetes rejects any
change to it, because changing which Pods a Deployment claims would orphan
the ones it used to own. When one label map fed both the selector and the
Pod template (as it did before topology spreading landed), adding any new
label to Pods would have changed the selector too, wedging the reconciler
on every Deployment that already existed.
So: build_labels_from_instance is frozen and owns the selector, and
everything added afterwards goes here. Kubernetes only requires that the
selector matches the template labels, so the template may carry extras.
Service selectors are subset matches and are unaffected.
§Extra labels
bindy.firestoned.io/cluster— the owning cluster, taken fromspec.clusterRef. Without it there is no label shared by the sibling single-Pod Deployments of a cluster, and so no way to write a topology spread selector that balances all primaries against each other.bindy.firestoned.io/role— derived fromspec.rolerather than from the CR’s metadata, so it is present even on a hand-writtenBind9Instancethat carries no role label. Only inserted when the selector does not already carry the key, so the Pod can never stop matching its own Deployment’s selector.