This note originally lived inside a very specific service setup, but the reusable part was the tunnel pattern.
The real question was: how do I expose a TCP service from Kubernetes through Cloudflare Tunnel without publishing the raw internal endpoint directly?
1. Create the Tunnel Credentials
The source workflow started from a machine with cloudflared installed:
| |
That produces:
- an origin certificate
- a tunnel credentials JSON file
Both should be treated as sensitive material.
2. Store the Credentials in Kubernetes
The next practical step was to put those files into Kubernetes secrets:
| |
That part matters because a surprising number of “Cloudflare Tunnel on Kubernetes” examples stop before they describe how the runtime actually gets the credentials.
3. Define the Tunnel Config
The useful shape of the cloudflared config map looked like this:
| |
The original note was tied to a specific service and domain. I have generalized both here.
4. Run the Deployment
The deployment pattern was straightforward:
| |
That is the point where the pattern becomes operational instead of conceptual.
5. Validate the Tunnel Mapping
Two checks from the original note are worth keeping:
| |
Those checks are useful because they tell you whether the config inside the running pod actually matches what you think you deployed.
Closing Thought
The nice thing about this pattern is that it works for more than just one app. Once you have the basic cloudflared deployment and secret flow in place, exposing another TCP service is mostly a matter of changing the hostname and the target service.