add component-specific pod anti-affinity to aggregator and server deployments#224
add component-specific pod anti-affinity to aggregator and server deployments#224pinkneyj wants to merge 1 commit into
Conversation
Greptile SummaryThis PR fixes component-specific pod anti-affinity for the aggregator and server deployments by introducing a local
Confidence Score: 4/5Safe to merge; the affinity logic is correct and the label values match what the pods actually get at runtime. The core change is sound — app.kubernetes.io/name values in the new matchLabels are confirmed to match what generateLabels emits for each component, merge order correctly lets user affinity win, and deepCopy prevents mutation of chart values. The only note is a pre-existing copy-paste in aggregator-deploy.yaml where topologySpreadConstraints and terminationGracePeriodSeconds still reference .Values.server.* instead of .Values.aggregator.*; this file is being touched, making it a natural time to clean up, but it does not affect the new affinity logic. aggregator-deploy.yaml — pre-existing wrong values references at lines 183–187 are worth fixing while the file is open Important Files Changed
|
By submitting a PR to this repository, you agree to the terms within the CloudZero Code of Conduct. Please see the contributing guidelines for how to create and submit a high-quality PR for this repo.
Please note that changes to the
cloudzero-agentHelm chart should be made instead in thehelm directoryin the cloudzero-agent repository, and will automatically be mirrored to this repository as soon as they are merged.Description
The aggregator-deploy.yaml template passed only defaults.affinity to the generateAffinity helper, with no component-specific anti-affinity logic. This caused any label set in defaults.affinity to be applied to all components indiscriminately — for example, setting an aggregator-targeted matchLabels in defaults would incorrectly propagate that label selector to the server deployment, making the server avoid nodes running aggregator pods rather than other server pods.
This change brings aggregator-deploy.yaml and agent-deploy.yaml (server) in line with the existing pattern used in webhook-deploy.yaml: each template now constructs a $podAntiAffinity variable with its own component-specific app.kubernetes.io/name label, merges it with any user-supplied affinity from values, and passes the result to generateAffinity. This ensures each component's pod anti-affinity rule targets the correct peer pods, and that defaults.affinity is no longer required to carry component-specific label selectors.
No breaking changes. The aggregator.affinity and server.affinity values fields continue to work as user overrides.
References
Pattern sourced from existing webhook-deploy.yaml implementation (lines 106–108)
Testing
Tested by deploying the Helm chart to a Kubernetes cluster and verifying:
Aggregator pods have matchLabels: app.kubernetes.io/name: aggregator in their anti-affinity spec
Server pods have matchLabels: app.kubernetes.io/name: server in their anti-affinity spec
Neither component inherits the other's label selector
defaults.affinity can be set to {} without affecting component-specific anti-affinity behaviour
labels can be manually set for one component without others being changed eg app.kubernetes.io/part-of: cloudzero-agent set for aggregator while others remain unchanged
This change adds test coverage for new/changed/fixed functionality
Checklist
main