Skip to content

fix(k8s): the cloudflared tunnel replicas prefer different nodes and keep one up through a drain - #2499

Merged
dan-petty merged 2 commits into
mainfrom
fix/1023-cloudflared-spread
Oct 28, 2026
Merged

dan-petty merged 2 commits into
mainfrom
fix/1023-cloudflared-spread

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

Deployment cloudflared ran 2 replicas with no anti-affinity and no PodDisruptionBudget. Both tunnel connectors could land on one node, and the loss or drain of that node cut all external ingress, because every external request comes in through the tunnel. kube-linter 0.8.3 reported no-anti-affinity on k8s/cloudflared/deployment.yaml.

  • The pod template has a preferred podAntiAffinity term on kubernetes.io/hostname that selects the pods with app.kubernetes.io/name: cloudflared. The scheduler places the two replicas on different nodes when it can. The term is soft, so a replica still starts while only one node can take it. A topologySpreadConstraints entry alone does not pass kube-linter's check, and a required term leaves a replica Pending while a node is offline.
  • The new PodDisruptionBudget cloudflared (k8s/cloudflared/pdb.yaml) has minAvailable: 1, so a drain evicts a tunnel connector only while another one is available. It sets unhealthyPodEvictionPolicy: AlwaysAllow, so a pod that is not ready, and so serves no traffic, never blocks a drain. kube-linter's pdb-unhealthy-pod-eviction-policy check asks for this.
  • k8s/cloudflared/kustomization.yaml lists pdb.yaml. Argo CD's base Application syncs it; the AppProjects restrict no namespaced kind.
  • k8s/README.md describes the placement and lists pdb.yaml.
  • The new capability cloudflared-tunnel-availability holds both requirements, and tests/test_k8s_cloudflared.py asserts them offline.

Closes #1023

Change: openspec/changes/archive/2026-10-28-1023-cloudflared-spread/

…keep one up through a drain

Deployment `cloudflared` ran 2 replicas with no anti-affinity and no
PodDisruptionBudget, so both tunnel connectors could land on one node,
and the loss or drain of that node cut all external ingress. kube-linter
reported `no-anti-affinity` on the file.

- The pod template has a preferred `podAntiAffinity` term on
  `kubernetes.io/hostname` that selects the cloudflared pods. The term is
  soft, so a replica still starts while only one node can take it.
- PodDisruptionBudget `cloudflared` (`minAvailable: 1`,
  `unhealthyPodEvictionPolicy: AlwaysAllow`) keeps one replica up through
  a drain, and a pod that is not ready never blocks one.
- `k8s/README.md` describes the placement and lists `pdb.yaml`.
@dan-petty

Copy link
Copy Markdown
Owner Author

Test and check evidence:

  • uv run devops ci fail-to-pass --base origin/main: 3 failed on base, 4 passed. test_cloudflared_replicas_prefer_different_nodes failed with (True, [], [], [], False) == (True, ['kubernetes.io/hostname'], ...), test_cloudflared_drain_keeps_one_tunnel_replica_available failed with [] == [('policy/v1', 1, 'AlwaysAllow', True)], and test_cloudflared_manifest_files_exist failed because pdb.yaml did not exist.
  • On the branch: tests/test_k8s_cloudflared.py, tests/invariants/test_k8s_manifests.py and tests/test_k8s_network_policies.py: 48 passed.
  • kube-linter lint k8s/cloudflared/ (0.8.3, the tools.lock version): before, no-anti-affinity; with the term only, pdb-unhealthy-pod-eviction-policy on the new budget; after, "No lint errors found!".
  • kubectl apply -k k8s/cloudflared/ --dry-run=server (Kubernetes v1.31.4+k3s1): the Deployment is configured, the PodDisruptionBudget is created, and the server keeps unhealthyPodEvictionPolicy: AlwaysAllow. Nothing was applied: Argo CD applies the change after the merge.
  • Live placement on 2026-10-28, read only: 2 of 2 replicas ready, one pod on each of two nodes, no PodDisruptionBudget; four nodes are ready.

Pending a person: after Argo CD syncs the merge, kubectl -n cloudflared get pods,pdb -o wide shows the two pods on different nodes and the budget with 1 allowed disruption, and kubectl drain <node> --dry-run=server of one pod's node evicts that pod while the other stays running.

Pending a person: review the diff in tuicr (tuicr -r origin/main..HEAD).

@dan-petty
dan-petty marked this pull request as ready for review October 28, 2026 18:57
@dan-petty
dan-petty merged commit d4edaf6 into main Oct 28, 2026
17 checks passed
@dan-petty
dan-petty deleted the fix/1023-cloudflared-spread branch October 28, 2026 18:57
dan-petty pushed a commit that referenced this pull request Oct 28, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.11.0](v0.10.1...v0.11.0)
(2026-10-28)


### Features

* **monitoring:** the roadmap Service's identity refusals, failing and
stalled jobs, restarts, and GitHub and model request volume raise alerts
([#2496](#2496))
([0137f23](0137f23)),
closes [#2472](#2472)
* **service:** roadmap-service runs at one replica, and each model call
in the cluster is sent at most two times
([#2500](#2500))
([2d32dae](2d32dae)),
closes [#2494](#2494)


### Bug Fixes

* **cli:** every command reports a DevOpsCLIError through one exit seam
([#2502](#2502))
([eadd55f](eadd55f)),
closes [#2487](#2487)
* **github:** pr monitor waits until the checks settle and names every
blocker, and pr ready reads the merge-readiness verdict
([#2498](#2498))
([43326ea](43326ea))
* **k8s:** a pod that does not call the Kubernetes API mounts no service
account token
([#2522](#2522))
([305d3ba](305d3ba))
* **k8s:** the cloudflared tunnel replicas prefer different nodes and
keep one up through a drain
([#2499](#2499))
([d4edaf6](d4edaf6)),
closes [#1023](#1023)
* **k8s:** the grafana, prometheus, argo cd and loki clients dial
through the egress-checked factory, and their pre-flight address checks
go ([#2497](#2497))
([e7ca1d5](e7ca1d5))
* **monitoring:** the roadmap Service alerts count a series that starts
in the hour, and a lane of a new pod can stall
([#2514](#2514))
([c7692b2](c7692b2)),
closes [#2505](#2505)
* **review:** a review's scanners leave out the rules that never gave a
valid finding here
([#2508](#2508))
([fe953ac](fe953ac))
* **roadmap:** a refine round leaves an outside account issue to a
person, and refine neutralizes comment openers, www links and
cross-repository references
([#2507](#2507))
([e6230dc](e6230dc)),
closes [#2478](#2478)
* **sandbox:** the metrics scrape and the whitelist NetworkPolicy
resolve each host one time, through the egress check
([#2521](#2521))
([7c01426](7c01426))
* **security:** the subprocess environment guard refuses the zsh and
interpreter keys that make a child run code
([#2510](#2510))
([459621a](459621a))
* **service:** a restart keeps the halt, the budget window and the
failure ledger, and a rate limit or a suspended installation stops every
worker ([#2515](#2515))
([3630de1](3630de1)),
closes [#2474](#2474)


### Code Refactoring

* **config:** settings resolve in one declared order through
pydantic-settings sources
([#2518](#2518))
([6a5447a](6a5447a)),
closes [#2445](#2445)

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
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.

fix(k8s): cloudflared's two tunnel replicas spread across nodes and keep one up through a drain

1 participant