Skip to content

Instantly share code, notes, and snippets.

@pew
Created September 9, 2022 07:18
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pew/3d99a1d2bf06ae64dd64fd6cfaf7f83a to your computer and use it in GitHub Desktop.
Save pew/3d99a1d2bf06ae64dd64fd6cfaf7f83a to your computer and use it in GitHub Desktop.
kubernetes / k8s cloudflare tunnel deployment
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
tunnel: cf-tunnel
name: cf-tunnel
namespace: default
spec:
replicas: 4 # you might want to adjust the replicas to your own needs
selector:
matchLabels:
tunnel: cf-tunnel
strategy:
rollingUpdate:
maxSurge: 0
maxUnavailable: 1
template:
metadata:
labels:
tunnel: cf-tunnel
spec:
containers:
- args:
- tunnel
- --no-autoupdate
- --metrics
- 0.0.0.0:8081
- run
- --token
- $(token)
envFrom:
- secretRef:
name: cf-tunnel
env:
- name: TZ
value: UTC
image: cloudflare/cloudflared:latest # you might want to pin this to a version
imagePullPolicy: Always
livenessProbe:
failureThreshold: 3
httpGet:
path: /ready
port: 8081
initialDelaySeconds: 10
periodSeconds: 10
name: tunnel
ports:
- containerPort: 8081
name: http-metrics
---
apiVersion: v1
data:
token: <cloudflare authentication token base64 encoded>
kind: Secret
metadata:
name: cf-tunnel
namespace: default
type: Opaque
@siretart
Copy link

you could simplify this config a bit by choosing the environment variable TUNNEL_TOKEN instead of token. In that case, you don't need to pass the option --tunnel and delete lines 29 and 30.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment