Skip to content

CP-43967: fix webhook pod anti-affinity selector - #882

Merged
evan-cz merged 1 commit into
developfrom
CP-43967-webhook-antiaffinity-selector
Jul 1, 2026
Merged

CP-43967: fix webhook pod anti-affinity selector#882
evan-cz merged 1 commit into
developfrom
CP-43967-webhook-antiaffinity-selector

Conversation

@evan-cz

@evan-cz evan-cz commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

What

The webhook server Deployment hardcodes a soft podAntiAffinity intended to spread replicas across nodes for high availability. Its selector matched on a bare app: webhook-server label that no webhook pod actually carries — pods are labeled app.kubernetes.io/name: webhook-server (via the chart's generateLabels helper), and the chart never emits a bare app: label anywhere.

As a result the rule matched zero pods and was a silent no-op: the default 3 webhook replicas could all be scheduled onto a single node, despite the template advertising "High availability: Multiple replicas with anti-affinity for fault tolerance."

Fix

Correct the selector key to app.kubernetes.io/name: webhook-server so the existing soft rule (preferred, weight 100, topologyKey: kubernetes.io/hostname) actually spreads replicas across nodes. It remains a preferred constraint, so it never blocks scheduling on small or single-node clusters. Operator-supplied affinity via insightsController.server.affinity continues to take precedence (the merge behavior is unchanged), and the template's HA claim is now accurate.

The $podAntiAffinity dict literal is also reformatted across multiple lines, matching the chart's existing style, for readability — no behavior change.

Tests

  • New helm unit test asserting the anti-affinity selector matches the real pod label, the dead bare app key is gone, and the rule stays soft (weight 100 / hostname topology).
  • Full helm unit suite passes (626 tests); helm lint clean.
  • Regenerated tests/helm/template/ baselines — the only rendered change across all topologies is the selector key flip.

@evan-cz
evan-cz requested a review from a team as a code owner June 30, 2026 21:09
The webhook Deployment's hardcoded podAntiAffinity selected on a bare
`app: webhook-server` label that no pod carries — pods are labeled
`app.kubernetes.io/name: webhook-server` via cloudzero-agent.generateLabels.
The rule matched zero pods and never spread the (default 3) webhook
replicas across nodes, despite the template header advertising HA via
anti-affinity.

Correct the selector key to app.kubernetes.io/name so the existing soft
(preferred, weight 100, kubernetes.io/hostname) rule actually spreads
replicas, and format the $podAntiAffinity dict across multiple lines for
readability. Behavior is unchanged for operators who override
insightsController.server.affinity, which still takes precedence.

- Add helm unit test asserting the selector matches the real pod label,
  the dead bare `app` key is gone, and the rule stays soft.
- Regenerate tests/helm/template baselines (selector key flip across all
  topologies; no other rendered changes).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@evan-cz
evan-cz added this pull request to the merge queue Jul 1, 2026
Merged via the queue into develop with commit 65e00dc Jul 1, 2026
43 of 44 checks passed
@evan-cz
evan-cz deleted the CP-43967-webhook-antiaffinity-selector branch July 1, 2026 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants