feat: add pod anti-affinity for multi-replica cloudflared connector#297
Open
conrado wants to merge 1 commit intoSTRRL:masterfrom
Open
feat: add pod anti-affinity for multi-replica cloudflared connector#297conrado wants to merge 1 commit intoSTRRL:masterfrom
conrado wants to merge 1 commit intoSTRRL:masterfrom
Conversation
Spread connector pods across nodes when replicas > 1 using requiredDuringSchedulingIgnoredDuringExecution anti-affinity. Adds needsUpdate check so existing deployments pick up the affinity on the next reconcile cycle. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #297 +/- ##
===========================================
+ Coverage 27.54% 50.06% +22.52%
===========================================
Files 10 11 +1
Lines 697 749 +52
===========================================
+ Hits 192 375 +183
+ Misses 503 351 -152
- Partials 2 23 +21
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When the cloudflared connector runs with multiple replicas, pods can be scheduled on the same node — defeating the purpose of HA. This PR adds
requiredDuringSchedulingIgnoredDuringExecutionpod anti-affinity to the connector Deployment template so pods are spread across nodes.replicas > 1(no-op for single replica)needsUpdatecheck so existing deployments pick up the change on the next reconcile cycleChanges
pkg/controller/controlled-cloudflared-connector.go:buildPodAntiAffinity()— returns anti-affinity withtopologyKey: kubernetes.io/hostnamewhen replicas > 1, nil otherwiseaffinityEqual()— compares two Affinity pointers for the needsUpdate checkAffinityincloudflaredConnectDeploymentTemplating()PodSpecpkg/controller/controlled-cloudflared-connector_test.go:TestCloudflaredConnectDeploymentTemplating— 4 subtests covering affinity, labels, container configTestBuildPodAntiAffinity— 3 subtests for 0, 1, and multiple replicasTestAffinityEqual— nil/non-nil/equal comparisonsTest plan
go test ./pkg/controller/...)minAvailable: 2works alongside the anti-affinity