Skip to content

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

Description

@dan-petty

Problem

k8s/cloudflared/deployment.yaml:11 runs 2 replicas with no topologySpreadConstraints or pod anti-affinity, and the cloudflared namespace has no PodDisruptionBudget. Both tunnel connectors can land on one node, and losing or draining that node cuts all external ingress. Today the pods happen to sit on two nodes. kube-linter's no-anti-affinity check flagged it in every branch review on 2026-10-02 (S1 to S6), and S5 verified it (.data/review-evaluation-20261002-s5.md, section 6.3).

Acceptance criteria

  • The Deployment has a topologySpreadConstraints entry on kubernetes.io/hostname with maxSkew: 1 and whenUnsatisfiable: ScheduleAnyway, so a rollout does not block while a node is offline.
  • A PodDisruptionBudget with minAvailable: 1 selects the cloudflared pods.
  • An offline test parses the manifests and asserts both.
  • kube-linter's anti-affinity check is clean on the file.
  • uv run devops ci passes.
  • (person-run) After kubectl apply, kubectl -n cloudflared get pods -o wide shows the two pods on different nodes, and a kubectl drain --dry-run=server of one node leaves a pod running.

Key questions

  • requiredDuringScheduling anti-affinity instead? (proposed) No. With a node offline (workhorse is), a hard rule would leave a replica Pending. A soft spread keeps both running.

Depends on: none.
Order: any time.
Related: #953 (network policies in the same stack).

Update 2026-10-08: refinement

Measured with kube-linter 0.8.3: a topologySpreadConstraints entry still fails no-anti-affinity; a preferred podAntiAffinity term passes and stays soft.

  • (replaces the first criterion) The Deployment has a preferred podAntiAffinity term on kubernetes.io/hostname selecting the cloudflared pods; the test asserts it and the PodDisruptionBudget.

Activity

  1. added
    scope/k8s
    priority/p3-low
    on Oct 2, 2026
  2. added
    status/ready
    effort/low
    value/low
    on Oct 28, 2026
  3. added a commit that references this issue on Oct 28, 2026
  4. added
    type/bug
    and removed
    status/ready
    on Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/lowpriority/p3-lowscope/k8stype/bugvalue/low

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions