cloudflared
by lola.2lannoy
Cloudflare Tunnel connector (cloudflared) running as a hardened, highly available Deployment
About this chart
cloudflared
Cloudflare Tunnel connector (cloudflared) running as a hardened, highly available Deployment
Runs cloudflared as a Deployment of tunnel connectors. Every replica is one more connector of the same tunnel (4 connections to Cloudflare each), so replicas give availability and capacity. A DaemonSet is deliberately not offered: Cloudflare caps a tunnel at 25 replicas / 100 connections, and connectors do not need to run next to the origins.
Install
The chart never creates the tunnel Secret: credentials must not live in Helm values, release history or Git. Create it first, then install.
Token mode (default)
For a tunnel managed in the Cloudflare dashboard (remotely managed: ingress rules live in Cloudflare, not in this chart).
kubectl create namespace cloudflared
kubectl -n cloudflared create secret generic cloudflared --from-file=token=./tunnel-token.txt
helm install cloudflared oci://ghcr.io/spnngl/charts/cloudflared --version <version> -n cloudflared
The Secret is named after the release (tunnel.token.existingSecret.name to
override, key defaults to token). Local config.originRequest and
warp-routing are ignored by cloudflared in this mode and rejected by the
schema.
Credentials mode
For a tunnel created with cloudflared tunnel create (locally managed:
ingress rules are tunnel.credentials.ingress in this chart).
kubectl -n cloudflared create secret generic cloudflared --from-file=credentials.json=./<tunnel-uuid>.json
helm install cloudflared oci://ghcr.io/spnngl/charts/cloudflared --version <version> -n cloudflared \
--set tunnel.mode=credentials --set tunnel.credentials.tunnel=<tunnel-uuid> \
--values ingress.yaml # tunnel.credentials.ingress: [..., {service: http_status:404}]
tunnel.credentials.tunnel must be the tunnel UUID: resolving a tunnel
name needs the account cert.pem, which the chart does not mount.
Other cloudflared options go in config (cloudflared config.yaml keys).
Keys the chart owns (metrics, token-file, credentials-file, tunnel,
ingress, grace-period, ...) are rejected there.
Secret rotation
cloudflared reads the token / credentials once at startup. After rotating the Secret, restart the pods:
kubectl -n cloudflared rollout restart deployment/cloudflared
or let Reloader do it with
podAnnotations: {reloader.stakater.com/auto: "true"}.
Image
The default image is appVersion pinned by the digest recorded in the
artifacthub.io/images annotation of Chart.yaml (Renovate updates both
together). Setting image.tag drops that digest; add image.digest to pin
the tag again (image.digest without image.tag is an error).
Cloudflare does not sign the image (no cosign signature, no attestations, checked on 2026.10.0). The digest pin only guarantees that the same bytes are pulled every time, not who built them.
Availability and scheduling
- 3 replicas,
RollingUpdatewithmaxUnavailable: 0,maxSurge: 1, and aterminationGracePeriodSecondsofgracePeriodSeconds + 15: cloudflared drains connections on SIGTERM. - Default spread: preferred pod anti-affinity on the hostname, preferred
topology spread over zones.
affinity/topologySpreadConstraintsreplace these defaults. - Replicas (or
autoscaling.maxReplicas) plus the rollout surge must stay at or below 25, the Cloudflare cap per tunnel. The chart fails otherwise. podDisruptionBudget.enabledis off by default.- Origins: cloudflared resolves origin hostnames itself. Use fully qualified
names with a trailing dot (
app.default.svc.cluster.local.): with the cluster defaultndots, a name with exactly two dots is otherwise tried against every search domain first. The chart setsndots: 2.
Autoscaling
autoscaling(HPA) scales on CPU utilization by default. CPUUtilizationis a percentage ofresources.requests.cpu: with the 50m floor, the default 75% target fires at about 38m. Size the requests first (VPA inOffmode gives recommendations), or scale on a connection metric such ascloudflared_tunnel_concurrent_requests_per_tunnelthrough prometheus-adapter or KEDA: CPU is a weak signal for a network-bound proxy.- Each pod removed drops four edge connections, hence the slow scale-down
default (
stabilizationWindowSeconds: 300). - Enabling the HPA after install drops the Deployment
replicasfield: the first apply scales to 1 until the HPA acts (Kubernetes behaviour). verticalPodAutoscalersupportsOff,Initial,RecreateandInPlaceOrRecreate(VPA 1.8+, in-place resize needs Kubernetes 1.33+). HPA and VPA must not act on the same resource: with the HPA on, keep the VPA inOffor drop that resource fromcontrolledResources.
Resources
The defaults are scheduling floors, not a sizing: requests 50m CPU /
64Mi memory, a 256Mi memory limit and no CPU limit (throttling adds
latency to a proxy). Cloudflare sizes whole hosts (4 CPU / 4 GiB for about
4000 WARP users), and throughput is bounded by ports, not CPU: the chart sets
net.ipv4.ip_local_port_range to 11000 60999 and cloudflared wants a
file-descriptor limit of at least 70000 (Go raises the soft limit to the
runtime's hard limit). Measure, then tune.
With a memory limit set, GOMEMLIMIT follows it, and a memory resize restarts
the container so the value never goes stale.
QUIC (UDP) benefits from larger socket buffers: raise net.core.rmem_max /
net.core.wmem_max on the nodes if cloudflared logs a buffer size warning.
Security
Defaults satisfy the restricted Pod Security Standard: non-root uid/gid
65532, read-only root filesystem, all capabilities dropped, no privilege
escalation, RuntimeDefault seccomp, no ServiceAccount token, no Service
environment variables. cloudflared needs no capability: ICMP proxying uses
unprivileged ICMP sockets, enabled by the net.ipv4.ping_group_range sysctl
(a safe sysctl).
Not defaulted, because each makes the kubelet refuse the pod on some nodes:
appArmorProfile (hosts without AppArmor) and supplementalGroupsPolicy: Strict (runtimes without support). Set them in podSecurityContext /
securityContext if your nodes support them.
User namespaces
hostUsers: false (default) runs the pod in a user namespace: uid 65532 in
the pod maps to an unprivileged host uid, which limits what a container escape
gains. Nodes need a container runtime with user namespace support
(containerd 2.0+ or CRI-O), runc 1.2+ or crun, and a Linux kernel 6.3+
(idmapped mounts on tmpfs for Secret and ConfigMap volumes); see the
Kubernetes documentation on user namespaces. On other nodes the pod sandbox
cannot be created (event on the pod, for example error mounting "sysfs" to rootfs ... operation not permitted on kind inside a CI runner): set hostUsers: true.
Writable paths
The root filesystem is read-only and cloudflared writes nothing by default.
logfile, log-directory, pidfile and trace-output need a writable path:
add an emptyDir with extraVolumes / extraVolumeMounts.
Network
- Warning: the metrics port also serves
/debug/pprof,/config(remote ingress rules, origin URLs) and/diag/*. The NetworkPolicy (networkPolicy.enabled, on by default) restricts ingress to that port, but withnetworkPolicy.metrics.from: []any in-cluster source is allowed: set it to your Prometheus namespace / pods, and expose the port only throughmetrics.service/ the monitors when needed. networkPolicy.egress.enabled(off by default) allows DNS and the Cloudflare edge (7844, TCP and UDP) only. Origins are not covered: add them innetworkPolicy.egress.extraEgress. Overridedns.tofor NodeLocal DNSCache or a non-default DNS namespace,edge.toto restrict the edge ranges. Port 443 is not needed: cloudflared's start-up "Cloudflare API" precheck logs a failure without it, but it is informational (hard_fail=false) and the tunnel connects over 7844 (checked on kind with the policy enforced).metrics.serviceMonitorormetrics.podMonitor(not both) integrate with the Prometheus Operator; a PodMonitor needs no Service.metrics.prometheusRuleadds alerts and needs one of the monitors (the rules select thejoblabel it sets; do not rewritejobinrelabelings).CloudflaredTunnelDown(critical) fires when no replica is ready while some are desired, from kube-state-metrics:cloudflared_tunnel_ha_connectionscannot tell, it counts connections still retrying (an invalid token keeps it at 1 while/readyreturns 503).CloudflaredRegistrationFailingandCloudflaredOriginErrors(warning) read cloudflared's own metrics.helm testrunscloudflared tunnel readyagainst the metrics Service and succeeds once at least one connection is up (the Service only routes to ready pods, so it fails while no connector is registered). It exists only when the metrics Service is rendered (metrics.service.enabledor a ServiceMonitor) and there is at least one connector (replicaCount> 0 or autoscaling).
Compatibility
The values schema is strict: unknown keys fail the install. A breaking change to values bumps the chart MAJOR version; deprecations are announced one MINOR version ahead. Requires Kubernetes 1.33 or later.
Maintainers
| Name | Url | |
|---|---|---|
| spnngl | https://github.com/spnngl |
Source Code
Requirements
Kubernetes: >=1.33.0-0
Values
| Key | Type | Default | Description |
|---|---|---|---|
| affinity | object | {} | Affinity. Empty: preferred podAntiAffinity on hostname. A non-empty value replaces that default wholesale. |
| autoscaling.behavior | object | {"scaleDown":{"stabilizationWindowSeconds":300}} | HPA behavior. Slow scale-down: each removed pod drops four edge connections. |
| autoscaling.enabled | bool | false | Create a HorizontalPodAutoscaler. Enabling it drops replicas from the Deployment: it falls to 1 until the HPA reacts. |
| autoscaling.maxReplicas | int | 10 | HPA maximum replicas (the rollout surge counts toward the 25 per tunnel cap). |
| autoscaling.metrics | list | [{"resource":{"name":"cpu","target":{"averageUtilization":75,"type":"Utilization"}},"type":"Resource"}] | Raw autoscaling/v2 MetricSpec list. CPU Utilization is a percentage of resources.requests.cpu: with the 50m floor, 75% fires at ~38m, so size requests first. |
| autoscaling.minReplicas | int | 3 | HPA minimum replicas. |
| config | object | {} | Free-form cloudflared configuration (config.yaml), any flag works (loglevel, protocol, edge-ip-version, warp-routing, originRequest, ...). Chart-owned keys are rejected; originRequest and warp-routing are also rejected in token mode (remote configuration owns them). |
| dnsConfig | object | {"options":[{"name":"ndots","value":"2"}]} | DNS config. |
| dnsConfig.options | list | [{"name":"ndots","value":"2"}] | DNS options (fewer search-list lookups for origin FQDNs). |
| extraArgs | list | [] | Extra cloudflared tunnel options, placed after --config and before run (for example --output=json). run-only options do not parse there: set them in config. |
| extraEnv | list | [] | Extra environment variables (EnvVar list) for the cloudflared container, for flags config.yaml does not read (for example TUNNEL_LOG_OUTPUT: json). Rendered after GOMEMLIMIT. |
| extraVolumeMounts | list | [] | Extra volume mounts for the cloudflared container. |
| extraVolumes | list | [] | Extra volumes (for example an origin CA bundle for originRequest.caPool, or an emptyDir for logfile/pidfile: the root filesystem is read-only). |
| fullnameOverride | string | "" | Override the full resource name (default <release>-<chart>). |
| gracePeriodSeconds | int | 30 | Drain time after SIGTERM (grace-period); terminationGracePeriodSeconds is this + 15. |
| hostUsers | bool | false | Run the pod in a user namespace (false: container root/uid 65532 maps to an unprivileged host uid). Needs node support (containerd 2.0+ or CRI-O, runc 1.2+, kernel 6.3+); pods fail to start otherwise. true uses host users. |
| image.digest | string | "" | Image digest, only valid together with image.tag. |
| image.pullPolicy | string | "IfNotPresent" | Image pull policy. |
| image.repository | string | "docker.io/cloudflare/cloudflared" | Image repository. |
| image.tag | string | "" | Image tag. Empty: appVersion pinned by the digest recorded in Chart.yaml. When set, the chart digest is not applied; add image.digest to pin it. |
| imagePullSecrets | list | [] | Image pull secrets (list of {name: <secret>}). |
| livenessProbe | object | {"failureThreshold":3,"httpGet":{"path":"/healthcheck","port":"metrics"},"periodSeconds":10} | Liveness probe, /healthcheck (process alive only). Not /ready: an edge outage must not restart every pod, cloudflared reconnects by itself. |
| metrics.podMonitor.enabled | bool | false | Create a Prometheus Operator PodMonitor (no Service needed). Exclusive with serviceMonitor. |
| metrics.podMonitor.interval | string | "" | Scrape interval (empty: Prometheus default). |
| metrics.podMonitor.labels | object | {} | Extra labels. |
| metrics.podMonitor.metricRelabelings | list | [] | Metric relabelings. |
| metrics.podMonitor.relabelings | list | [] | Relabelings. |
| metrics.podMonitor.scrapeTimeout | string | "" | Scrape timeout (empty: Prometheus default). |
| metrics.prometheusRule.disabled | list | [] | Alerts to leave out (at most two: disable prometheusRule instead). CloudflaredTunnelDown reads kube-state-metrics (kube_deployment_status_replicas_available, kube_deployment_spec_replicas): without it, it never f |
Deploy cloudflared with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has cloudflared on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartcloudflared is pinned at v0.2.9 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below opentenant validate opentenant.yaml terraform init && terraform apply