MCPcopy Index your code
hub / github.com/adyanth/cloudflare-operator

github.com/adyanth/cloudflare-operator @v0.13.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.13.1 ↗ · + Follow
293 symbols 719 edges 35 files 156 documented · 53%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Cloudflare Operator

Logo

A Kubernetes Operator to create and manage Cloudflare Tunnels and DNS records

for (HTTP/TCP/UDP*) Service Resources

<a href="https://github.com/adyanth/cloudflare-operator/blob/main/docs/getting-started.md"><strong>Getting Started Guide »</strong></a>






<a href="https://github.com/adyanth/cloudflare-operator/issues">Report Bug</a>
·
<a href="https://github.com/adyanth/cloudflare-operator/issues">Request Feature</a>

GitHub license GitHub forks GitHub stars GitHub issues Go Report Card

NOTE: This project is currently in Alpha

UDP*: UDP support for Cloudflare Tunnels is in Early Access

Motivation

The Cloudflare Tunnels guide for deployment on Kubernetes provides a manifest which is very bare bones and does not hook into Kubernetes in any meaningful way. The operator started out as a hobby project of mine to deploy applications in my home lab and expose them to the internet via Cloudflare Tunnels without doing a lot of manual work every time a new application is deployed.

Overview

The Cloudflare Operator aims to provide a new way of dynamically deploying the cloudflared daemon on Kubernetes. Scaffolded and built using operator-sdk. Once deployed, this operator provides the following:

  • Ability to create new and use existing Tunnels for Cloudflare for Teams using Custom Resources (CR/CRD) which will:
  • Accept a Secret for Cloudflare API Tokens and Keys
  • Run a scaled (configurable) Deployment of cloudflared
  • Manage a ConfigMap for the above Deployment
  • Have Cluster and Namespace scoped Tunnels
  • A TunnelBinding controller which does the following:
  • Update the cloudflared ConfigMap to include the new Services to be served under a given Tunnel
  • Restart the cloudflared Deployment to make the configuration change take effect
  • Add a DNS entry in Cloudflare for the specified domain to be a proxied CNAME to the referenced tunnel
  • Reverse the above when the TunnelBinding is deleted using Finalizers

Bird's eye view

Here is how the operator and the Tunnel Resource fit into your deployment.

Operator Architecture

There is more detailed information on this architecture and the thought process behind it in my blog post.

NOTE: This is NOT an official operator provided/backed by Cloudflare Inc. It utilizes their v4 API and their cloudflared to automate setting up of tunnels on Kubernetes.

Extension points exported contracts — how you extend this code

GenericReconciler (Interface)
(no doc) [3 implementers]
internal/clients/k8s/kubectl_apply.go
GenericTunnelReconciler (Interface)
(no doc) [2 implementers]
internal/controller/generic_tunnel_reconciler.go
Tunnel (Interface)
(no doc) [2 implementers]
internal/controller/tunnel.go

Core symbols most depended-on inside this repo

GetTunnel
called by 73
internal/controller/generic_tunnel_reconciler.go
GetObject
called by 35
internal/controller/tunnel.go
GetRecorder
called by 22
internal/clients/k8s/kubectl_apply.go
GetLog
called by 21
internal/clients/k8s/kubectl_apply.go
GetSpec
called by 20
internal/controller/tunnel.go
GetName
called by 12
internal/controller/tunnel.go
GetClient
called by 12
internal/clients/k8s/kubectl_apply.go
GetNamespace
called by 11
internal/controller/tunnel.go

Shape

Method 203
Struct 50
Function 37
Interface 3

Languages

Go100%

Modules by API surface

api/v1alpha1/zz_generated.deepcopy.go52 symbols
internal/controller/adapter.go26 symbols
api/v1alpha2/zz_generated.deepcopy.go22 symbols
internal/clients/cf/api.go20 symbols
internal/controller/generic_tunnel_reconciler.go19 symbols
internal/controller/tunnel_controller.go17 symbols
internal/controller/clustertunnel_controller.go17 symbols
internal/controller/tunnelbinding_controller.go16 symbols
internal/controller/tunnel.go12 symbols
internal/clients/k8s/kubectl_apply.go12 symbols
api/v1alpha1/tunnel_conversion.go11 symbols
internal/controller/accesstunnel/controller.go10 symbols

For agents

$ claude mcp add cloudflare-operator \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact