Skip to content

feat(chart): multi-replica Deployments spread across nodes by default; identity-gate flags follow the webhook; a SPIRE-served webhook without mesh SPIRE is documented as supported (#1412, #1428, #1432, #1434) - #1454

Merged
bpalermo merged 2 commits into
mainfrom
feat/1434-deployment-spread
Oct 8, 2026

Conversation

@bpalermo

@bpalermo bpalermo commented Oct 8, 2026 •

Copy link
Copy Markdown
Owner

Closes #1434
Closes #1432
Closes #1428
Closes #1412

Chart aether 2.4.19 -> 2.4.20 (rebased onto #1436, which took 2.4.19; the only conflict was the version line).

#1434: what was actually wrong

The issue says the registrar has no anti-affinity or topology spread. It has: since #635 the registrar and the edge render a soft hostname spread, and the controller a preferred anti-affinity term about its own replicas. The cluster the issue was observed on carries that constraint on the registrar Deployment, and both replicas (same ReplicaSet, created 28 s apart in one rollout) were on one of five workers anyway. So the question became why a soft rule that is there loses.

Measured on kind (pinned v0.33.0 / Kubernetes 1.35.8, one tainted control plane plus workers). The pods are stand-ins: the chart's rendered tolerations, affinity, topologySpreadConstraints, labels, selector and rollout strategy, with one pause container. The three Deployments are rolled together, as a chart upgrade rolls them, twenty times per variant; the number is how many rollouts ended with both replicas of a Deployment on one node (controller / edge / registrar).

Pod templates 2 workers 3 workers
main (measured at 2.4.18; #1436 did not touch these fields) 8 / 5 / 10 1 / 0 / 5
main without the controller's "off the registrars' node" term 0 / 6 / 2 0 / 0 / 1
matchLabelKeys added, that term kept (my first attempt) 9 / 0 / 11 1 / 0 / 3
this PR: matchLabelKeys added, that term gone 0 / 0 / 0 0 / 0 / 0

Two causes:

  1. The controller's default affinity preferred nodes without a registrar (TRIPLE-window liveness anomaly: 2-for-2 across consecutive soaks, different mechanism each time #629). The scheduler applies a preferred anti-affinity term in both directions, so each new registrar was also pushed off the nodes holding a controller. That score and the registrar's own spread score carry the same plugin weight, they cancelled, and the tie fell to the scheduler's other scores. This is the larger cause, and it also stacked the controllers.
  2. The constraint counted the old ReplicaSet's pods during a rollout. matchLabelKeys: [pod-template-hash] (on by default for spread constraints from Kubernetes 1.27) makes it count the new ReplicaSet alone. This is the smaller cause for the registrar and the whole cause for the edge's surge-free roll on two workers.

The first row is what I committed first, on the theory that (2) was the cause. The measurement said otherwise, so the PR changed.

What I did not establish: that the five-worker observation in the issue had exactly this mechanism. The scheduling events of that rollout were gone. The three-worker row (5 of 20 on main, 0 of 20 here) is the closest reproduction I have.

What changes

Why a spread constraint and not pod anti-affinity

  • matchLabelKeys is on by default for spread constraints from 1.27; for pod (anti-)affinity only from 1.31.
  • required cannot wedge a small cluster: DoNotSchedule with maxSkew: 1 refuses a node only while another counted node holds fewer replicas. Required anti-affinity leaves every replica beyond the node count Pending.
  • The chart has no Kubernetes floor of its own (the only one is 1.29, for the native authz sidecar, and only when that is enabled), so the field is rendered from 1.27 and left out below.

Render before / after

helm template aether charts/aether -n aether-system on main (re-run after the rebase onto #1436) and on this branch, compared as parsed objects (YAML comments dropped; the generated self-signed webhook pair and the helm.sh/chart object label masked).

Values Objects that differ
default Deployment controller, Deployment registrar
edge.enabled=true controller, registrar, edge
namespaceInjection=false, injectPodNdots=false controller, registrar
spire.enabled=false, controller.webhook.spire=true controller, registrar
default, --kube-version 1.26.0 controller only

No DaemonSet, RBAC object, webhook configuration or ConfigMap differs in any of them.

Registrar and edge pod templates, in every render on Kubernetes >= 1.27:

       topologySpreadConstraints:
       - maxSkew: 1
         topologyKey: kubernetes.io/hostname
         whenUnsatisfiable: ScheduleAnyway
         labelSelector:
           matchLabels:
             app.kubernetes.io/name: aether-registrar
             app.kubernetes.io/instance: aether
             app.kubernetes.io/component: registrar
+        matchLabelKeys:
+        - pod-template-hash

Controller pod template, in every render:

-      affinity:
-        podAntiAffinity:
-          preferredDuringSchedulingIgnoredDuringExecution:
-          - weight: 100
-            podAffinityTerm:
-              topologyKey: kubernetes.io/hostname
-              labelSelector:
-                matchExpressions:
-                - {key: app.kubernetes.io/part-of, operator: In, values: [aether]}
-                - {key: app.kubernetes.io/component, operator: In, values: [registrar]}
-          - weight: 100
-            podAffinityTerm:
-              topologyKey: kubernetes.io/hostname
-              labelSelector:
-                matchLabels:
-                  app.kubernetes.io/name: aether-controller
-                  app.kubernetes.io/instance: aether
-                  app.kubernetes.io/component: controller
+      topologySpreadConstraints:
+      - maxSkew: 1
+        topologyKey: kubernetes.io/hostname
+        whenUnsatisfiable: ScheduleAnyway
+        labelSelector:
+          matchLabels:
+            app.kubernetes.io/name: aether-controller
+            app.kubernetes.io/instance: aether
+            app.kubernetes.io/component: controller
+        matchLabelKeys:
+        - pod-template-hash

(below 1.27 without the last two lines). Controller, additionally and only with both webhook switches off (#1432):

         - --mesh-domain=aether.internal
-        - --identity-gate=true
-        - --identity-gate-image=<agent image>
-        - --identity-gate-image-pull-policy=IfNotPresent
-        - --identity-gate-workload-socket=/run/secrets/workload-spiffe-uds/socket
-        - --identity-gate-cpu-request=5m
-        - --identity-gate-memory-request=16Mi
-        - --identity-gate-cpu-limit=
-        - --identity-gate-memory-limit=64Mi
+        - --identity-gate=false

With the default (both switches on) the controller's arguments are unchanged: the only difference in its pod template is the scheduling block above. With spire.enabled=false and the SPIRE webhook on, the controller already had --identity-gate=false; the only difference is again the scheduling block.

What an operator sees on upgrade

  • The registrar, the controller and the edge (when enabled) each roll once, because their pod templates change. No DaemonSet rolls. Below Kubernetes 1.27 only the controller rolls.
  • That roll is what re-places replicas that share a node today. Nothing moves a running pod otherwise.
  • A release that sets controller.affinity keeps it. A release that relied on the default "off the registrars' node" preference loses it.
  • A release with both webhook switches off gets --identity-gate=false on the controller. The flags were inert.
  • Nothing to do, unless you want required.

After the upgrade (also in the runbook, "Chart 2.4.20"):

kubectl get pods -A \
  -l 'app.kubernetes.io/part-of=aether,app.kubernetes.io/component in (registrar,controller,edge)' \
  -o 'custom-columns=COMPONENT:.metadata.labels.app\.kubernetes\.io/component,POD:.metadata.name,NODE:.spec.nodeName' \
  --sort-by='.metadata.labels.app\.kubernetes\.io/component'

Single-node and small clusters

Run on a one-node kind cluster with the stand-in Deployments: with soft and with required, all six pods schedule, a rollout restart of the three (a surge pod on the same node) completes, and scaling each to three replicas leaves none Pending.

On a control plane plus two workers, required with three replicas and without nodeTaintsPolicy: Honor left the third replica of each Deployment Pending (the tainted control plane counts as an empty node nothing can be put on). That is why required renders Honor. Its price, also seen there: a node that is NotReady or cordoned is tainted too and is not counted while it is, so replicas may share another node meanwhile.

Tests

helm_template_* targets in charts/aether/BUILD.bazel, written first and run against the unchanged chart.

Red on main, green here (17):

  • aether_node_spread_default_{registrar,controller,edge}_test
  • aether_node_spread_required_{registrar,controller,edge}_test
  • aether_node_spread_none_test (the off switch)
  • aether_node_spread_invalid_{word,yaml_off}_test, aether_node_spread_required_old_kube_test (rejected values)
  • aether_node_spread_user_replaces_controller_test, aether_node_spread_old_kube_controller_test
  • aether_controller_default_affinity_test, aether_no_default_affinity_test, aether_controller_affinity_user_replaces_test
  • aether_identity_gate_no_mutating_webhook_{self_signed,spire}_test (chart: the identity-gate flags are passed to the controller when no mutating webhook renders #1432)

Guards, green before and after (8):

  • aether_node_spread_user_replaces_{registrar,edge}_test: a user's constraints replace the chart's, with nothing merged in.
  • aether_node_spread_old_kube_{registrar,edge}_test: below 1.27 the constraint is what main renders.
  • aether_identity_gate_{namespace_injection_only,ndots_only}_test: with either switch on the gate stays on.
  • aether_webhook_spire_without_mesh_spire_test and ..._absent_test (chart: controller.webhook.spire=true is accepted with spire.enabled=false #1412): the controller gets --spire-enabled, its csi.spiffe.io volume and --identity-gate=false; the agent and the registrar get --spire-enabled=false; no broker socket, no Workload API volume on the agent, the proxy or the registrar, no Secret.

bazel test //charts/... //bazel/helm/... (212 pass, after the rebase), the lint build and make format-check pass locally.

Not verified

  • The real chart was not installed on kind: the experiments use stand-in pods carrying the rendered scheduling fields (the final render was compared field for field with the measured variant), so they measure the scheduler, not the components.
  • Twenty rollouts per variant is a small sample. The differences between rows are large; the zeros mean "not seen in 20", not "impossible" for a soft rule.
  • Clusters with zones, resource pressure or other pods' affinity terms were not modelled. soft can still lose there; required is the answer when it must not.
  • With the edge's surge-free roll and matchLabelKeys, the first new edge replica is placed without regard to the old one still serving, so both live replicas can share a node during the roll. Not measured.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

Copilot AI balanced review requested due to automatic review settings October 8, 2026 16:29

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The upgrade documentation incorrectly guarantees that identity-gate images never require pulling during concurrent rollouts.

1 open finding
What changed in this PR

Adds configurable node spreading for multi-replica control-plane Deployments and aligns identity-gate flags with webhook availability.

Changes:

  • Adds shared soft|required|none node-spread behavior and tests.
  • Disables identity-gate flags when no mutating webhook renders.
  • Updates SPIRE and upgrade documentation; bumps chart to 2.4.20.
File Description
docs/​runbook.md Documents rollout and scheduling effects.
docs/​configuration.md Documents new settings and SPIRE behavior.
charts/​aether/​values.yaml Adds node-spread defaults and guidance.
charts/​aether/​templates/​registrar-deployment.yaml Uses shared spread helper.
charts/​aether/​templates/​edge-deployment.yaml Uses shared spread helper.
charts/​aether/​templates/​controller-deployment.yaml Replaces default affinity and gates identity flags.
charts/​aether/​templates/​agent-proxy-daemonset.yaml Clarifies SPIRE socket behavior.
charts/​aether/​templates/​_helpers.tpl Implements node-spread rendering and validation.
charts/​aether/​Chart.yaml Bumps chart version to 2.4.20.
charts/​aether/​BUILD.bazel Adds Helm rendering tests.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread docs/runbook.md Resolved
Copilot AI balanced review requested due to automatic review settings October 8, 2026 16:34
@bpalermo
bpalermo force-pushed the feat/1434-deployment-spread branch from 20cdff2 to 2f73eb2 Compare October 8, 2026 16:34
@bpalermo
bpalermo force-pushed the feat/1434-deployment-spread branch from 2f73eb2 to 7718b53 Compare October 8, 2026 16:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new operational documentation incorrectly describes cordoned-node handling and one measured affinity outcome.

2 open findings
1 resolved since last review

🧠 Review effort: Balanced

Comment thread charts/aether/templates/_helpers.tpl Resolved
Comment thread docs/runbook.md Resolved
Copilot AI balanced review requested due to automatic review settings October 8, 2026 16:37

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

It changes default production scheduling semantics across Kubernetes versions and warrants final human validation.

2 open findings

🧠 Review effort: Balanced

…; identity-gate flags follow the webhook; a SPIRE-served webhook without mesh SPIRE is documented as supported (#1412, #1428, #1432, #1434)

#1434: the registrar and the edge already rendered a soft hostname spread, and
the controller a preferred anti-affinity term about its own replicas; replicas
still ended up on one node. Measured on kind (a tainted control plane plus two
or three workers, the three Deployments rolled together twenty times), two
things defeated the spread:

- the controller's default preferred anti-affinity against the registrars'
  node. The scheduler applies such a term in both directions, so it pushed
  each new registrar off the nodes holding a controller with the weight of the
  registrar's own spread. That default is removed; controller.affinity is
  rendered only when set.
- the constraint counted the old ReplicaSet's pods during a rollout. It now
  carries matchLabelKeys: [pod-template-hash] (Kubernetes >= 1.27).

One helper, aether.nodeSpread, renders the constraint for the three
Deployments. <component>.nodeSpread picks soft (default), required
(DoNotSchedule plus nodeTaintsPolicy: Honor; refused below 1.27) or none; a
non-empty <component>.topologySpreadConstraints still replaces it outright.
The controller gains nodeSpread and topologySpreadConstraints.

#1432: --identity-gate=true and the gate's flags are passed only when the
mutating webhook renders (aether.controller.mutatingWebhook).

#1428: documented, no template change: the controller's --identity-gate-image
defaults to the agent image, so a new agent image rolls the controller.

#1412: spire.enabled=false with controller.webhook.spire=true is a supported
pair. values.yaml, docs/configuration.md and two comments said or implied
otherwise; a template test now pins that the pair renders coherently.

Chart 2.4.20.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The chart behavior, compatibility handling, documentation, and targeted render tests are consistent with the stated requirements.

0 open findings

2 resolved since last review

🧠 Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 8, 2026 17:55
@bpalermo
bpalermo enabled auto-merge (squash) October 8, 2026 17:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

It changes default scheduling behavior across Kubernetes versions, while validation used stand-in workloads rather than a complete chart installation.

0 open findings

🧠 Review effort: Balanced

@bpalermo
bpalermo merged commit 1b3c105 into main Oct 8, 2026
31 checks passed
@bpalermo
bpalermo deleted the feat/1434-deployment-spread branch October 8, 2026 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants