cloudflare-tunnel-operator

by Beez Innovation Labs Private Limited

Helm chartv0.2.0App 0.2.0

A Helm chart for cloudflare-tunnel-operator

About this chart

About this project

Cloudflare Tunnels allows us to access systems behind a firewall or ones without a static IP among other things. This can be incredibly useful for people running their own home servers as it enables them to expose applications running on those servers to the internet without needing to port forward or pay for a static IP.

But what about those running home Kubernetes clusters? One could run the tunnel application like any other application on Kubernetes but creating and destroying tunnels would either involve changing the config file in the cluster or using the Cloudflare Tunnel dashboard. This is certainly a valid way but might not be the ideal way, especially if you live and breathe GitOps.

That is where this project comes in. It allows you to create custom resources for Cloudflare Tunnels in your Kubernetes cluster. This means that the Tunnel will be active as long as your custom resource exists and will be updated if your custom resource is updated.

Built With

Installing

To install the chart with the release name my-cloudflare-tunnel-operator:

helm repo add beezlabs https://charts.beezlabs.app/
helm install my-cloudflare-tunnel-operator beezlabs/cloudflare-tunnel-operator --version 0.1.0

Usage

  1. Figure out the service that you want to connect to. In the below example, the service looks as following
    apiVersion: v1
    kind: Service
    metadata:
      name: traefik
      namespace: traefik
    spec:
      ports:
        - name: web
          nodePort: 30391
          port: 80
          protocol: TCP
          targetPort: web
        - name: websecure
          nodePort: 31118
          port: 443
          protocol: TCP
          targetPort: websecure
      selector:
        app.kubernetes.io/instance: traefik
        app.kubernetes.io/name: traefik
      type: LoadBalancer
    
  2. Create an API token in cloudflare which has access to all Zones and the DNS.
  3. Apply the examples updating the resources where needed
    kubectl apply -f examples/sampleTunnel/
    kubectl apply -f examples/secret/
    
  4. Check CloudflareTunnel object
    kubectl get cloudflaretunnel -A
    NAMESPACE    NAME            AGE
    cloudflare   sample-tunnel   3d21h
    
  5. Access the URL that is set as domain
    https://example.sayakm.me
    

Values

KeyTypeDefaultDescription
image.repositorystring"ghcr.io/beezlabs-org/cloudflare-tunnel-operator"The image of the operator
image.pullPolicystring"IfNotPresentThe image pull policy for the operator
image.tagstring"v0.1.0"The image tag ofe the operator

Current values file here

replicaCount: 1

image:
   repository: ghcr.io/beezlabs-org/cloudflare-tunnel-operator
   pullPolicy: IfNotPresent
   tag: 0.1.0

imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""

serviceAccount:
   create: true
   annotations: {}
   name: ""

podAnnotations: {}

podSecurityContext: {}
# fsGroup: 2000

securityContext: {}
        # capabilities:
        #   drop:
        #   - ALL
        # readOnlyRootFilesystem: true
        # runAsNonRoot: true
# runAsUser: 1000

resources: {}
        # limits:
        #   cpu: 100m
        #   memory: 128Mi
        # requests:
        #   cpu: 100m
#   memory: 128Mi

autoscaling:
   enabled: false
   minReplicas: 1
   maxReplicas: 100
   targetCPUUtilizationPercentage: 80
   # targetMemoryUtilizationPercentage: 80

nodeSelector: {}

tolerations: []

affinity: {}

License

Licensed under the Apache License, Version 2.0. Copyright Beez Innovation Labs Pvt Ltd.

Contact

Sayak Mukhopadhyay - SayakMukhopadhyay - [email protected]

Deploy cloudflare-tunnel-operator with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has cloudflare-tunnel-operator 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.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartcloudflare-tunnel-operator is pinned at v0.2.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. 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