|
7 | 7 | <br /> |
8 | 8 |
|
9 | 9 | <p align="center"> |
10 | | - A Kubernetes Operator to create and manage Cloudflare Tunnels and DNS records <br /> for (HTTP/TCP/UDP*) Service Resources |
| 10 | + A Kubernetes Operator for Cloudflare Zero Trust: Tunnels, Access, Gateway, and Device Management |
11 | 11 | <br /> |
12 | 12 | <br /> |
13 | 13 | <a href="https://github.com/adyanth/cloudflare-operator/blob/main/docs/getting-started.md"><strong>Getting Started Guide »</strong></a> |
|
28 | 28 |
|
29 | 29 | > **_NOTE_**: This project is currently in Alpha |
30 | 30 |
|
31 | | -> UDP*: UDP support for Cloudflare Tunnels is in [Early Access](https://blog.cloudflare.com/extending-cloudflares-zero-trust-platform-to-support-udp-and-internal-dns/) |
| 31 | +## Overview |
32 | 32 |
|
33 | | -## Motivation |
| 33 | +The Cloudflare Operator provides Kubernetes-native management of Cloudflare Zero Trust resources. Built with `operator-sdk`, it enables declarative configuration of tunnels, access policies, gateway rules, and device settings through Custom Resources (CRDs). |
34 | 34 |
|
35 | | -The [Cloudflare Tunnels guide](https://developers.cloudflare.com/cloudflare-one/tutorials/many-cfd-one-tunnel) for deployment on Kubernetes provides a [manifest](https://github.com/cloudflare/argo-tunnel-examples/tree/master/named-tunnel-k8s) 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. |
| 35 | +## Features |
36 | 36 |
|
37 | | -## Overview |
| 37 | +### Tunnel Management |
| 38 | +- **Tunnel / ClusterTunnel**: Create and manage Cloudflare Tunnels with scaled `cloudflared` deployments |
| 39 | +- **TunnelBinding**: Automatically configure tunnel ingress rules and DNS records for Services |
| 40 | +- **AccessTunnel**: Reference existing tunnels created outside of Kubernetes |
| 41 | +- **WARP Routing**: Enable private network access via WARP client (`enableWarpRouting`) |
| 42 | + |
| 43 | +### Private Network Access (ZTNA) |
| 44 | +- **VirtualNetwork**: Manage Cloudflare virtual networks for traffic isolation |
| 45 | +- **NetworkRoute**: Configure IP routes through tunnels to private networks |
| 46 | +- **PrivateService**: Expose Kubernetes Services to WARP clients via private IPs |
38 | 47 |
|
39 | | -The Cloudflare Operator aims to provide a new way of dynamically deploying the [cloudflared](https://github.com/cloudflare/cloudflared) daemon on Kubernetes. Scaffolded and built using `operator-sdk`. Once deployed, this operator provides the following: |
| 48 | +### Access Control |
| 49 | +- **AccessApplication**: Define Zero Trust applications with access policies |
| 50 | +- **AccessGroup**: Create reusable access groups with include/exclude/require rules |
| 51 | +- **AccessIdentityProvider**: Configure identity providers (OIDC, SAML, GitHub, Azure AD, etc.) |
| 52 | +- **AccessServiceToken**: Manage service tokens for machine-to-machine authentication |
40 | 53 |
|
41 | | -* Ability to create new and use existing Tunnels for [Cloudflare for Teams](https://developers.cloudflare.com/cloudflare-one/) using Custom Resources (CR/CRD) which will: |
42 | | - * Accept a Secret for Cloudflare API Tokens and Keys |
43 | | - * Run a scaled (configurable) Deployment of `cloudflared` |
44 | | - * Manage a ConfigMap for the above Deployment |
45 | | - * Have Cluster and Namespace scoped Tunnels |
46 | | -* A TunnelBinding controller which does the following: |
47 | | - * Update the `cloudflared` ConfigMap to include the new Services to be served under a given Tunnel |
48 | | - * Restart the `cloudflared` Deployment to make the configuration change take effect |
49 | | - * Add a DNS entry in Cloudflare for the specified domain to be a [proxied CNAME to the referenced tunnel](https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/routing-to-tunnel/dns) |
50 | | - * Reverse the above when the TunnelBinding is deleted using Finalizers |
| 54 | +### Gateway & Security |
| 55 | +- **GatewayRule**: Configure Cloudflare Gateway DNS, HTTP, and network policies |
| 56 | +- **GatewayList**: Manage lists (URLs, hostnames, IPs) for use in gateway rules |
| 57 | +- **GatewayConfiguration**: Global gateway settings and configurations |
51 | 58 |
|
52 | | -## Bird's eye view |
| 59 | +### Device Management |
| 60 | +- **DeviceSettingsPolicy**: Configure WARP client settings, split tunnels, and fallback domains |
| 61 | +- **DevicePostureRule**: Define device posture checks for Zero Trust access |
| 62 | + |
| 63 | +### DNS & Connectivity |
| 64 | +- **DNSRecord**: Manage Cloudflare DNS records |
| 65 | +- **WARPConnector**: Deploy WARP connectors for site-to-site connectivity |
| 66 | + |
| 67 | +## Architecture |
53 | 68 |
|
54 | 69 | Here is how the operator and the Tunnel Resource fit into your deployment. |
55 | 70 |
|
56 | 71 |  |
57 | 72 |
|
58 | | -There is more detailed information on this architecture and the thought process behind it in my [blog post](https://adyanth.site/posts/migration-compose-k8s/cloudflare-tunnel-operator-architecture/). |
| 73 | +## Quick Start |
| 74 | + |
| 75 | +### Prerequisites |
| 76 | +- Kubernetes cluster (v1.28+) |
| 77 | +- Cloudflare account with Zero Trust enabled |
| 78 | +- Cloudflare API Token with appropriate permissions |
| 79 | + |
| 80 | +### Installation |
| 81 | + |
| 82 | +```bash |
| 83 | +# Install CRDs |
| 84 | +kubectl apply -f https://github.com/adyanth/cloudflare-operator/releases/latest/download/cloudflare-operator.crds.yaml |
| 85 | + |
| 86 | +# Install operator |
| 87 | +kubectl apply -f https://github.com/adyanth/cloudflare-operator/releases/latest/download/cloudflare-operator.yaml |
| 88 | +``` |
| 89 | + |
| 90 | +### Create a Tunnel |
| 91 | + |
| 92 | +```yaml |
| 93 | +apiVersion: networking.cfargotunnel.com/v1alpha2 |
| 94 | +kind: Tunnel |
| 95 | +metadata: |
| 96 | + name: my-tunnel |
| 97 | + namespace: default |
| 98 | +spec: |
| 99 | + cloudflare: |
| 100 | + accountId: <your-account-id> |
| 101 | + domain: example.com |
| 102 | + secret: cloudflare-api-secret |
| 103 | + enableWarpRouting: true # Enable private network access |
| 104 | +``` |
| 105 | +
|
| 106 | +### Expose a Service |
| 107 | +
|
| 108 | +```yaml |
| 109 | +apiVersion: networking.cfargotunnel.com/v1alpha2 |
| 110 | +kind: TunnelBinding |
| 111 | +metadata: |
| 112 | + name: my-service-binding |
| 113 | + namespace: default |
| 114 | +spec: |
| 115 | + tunnelRef: |
| 116 | + name: my-tunnel |
| 117 | + subjects: |
| 118 | + - name: my-service |
| 119 | + spec: |
| 120 | + fqdn: app.example.com |
| 121 | + protocol: http |
| 122 | + target: my-service:8080 |
| 123 | +``` |
| 124 | +
|
| 125 | +## CRD Reference |
| 126 | +
|
| 127 | +| CRD | Scope | Description | |
| 128 | +|-----|-------|-------------| |
| 129 | +| `Tunnel` | Namespaced | Cloudflare Tunnel with managed cloudflared deployment | |
| 130 | +| `ClusterTunnel` | Cluster | Cluster-wide Cloudflare Tunnel | |
| 131 | +| `TunnelBinding` | Namespaced | Bind Services to Tunnels with DNS records | |
| 132 | +| `AccessTunnel` | Namespaced | Reference to external tunnel | |
| 133 | +| `VirtualNetwork` | Cluster | Cloudflare virtual network | |
| 134 | +| `NetworkRoute` | Cluster | IP route through tunnel | |
| 135 | +| `PrivateService` | Namespaced | Expose Service via WARP private IP | |
| 136 | +| `AccessApplication` | Namespaced | Zero Trust application | |
| 137 | +| `AccessGroup` | Namespaced | Access policy group | |
| 138 | +| `AccessIdentityProvider` | Namespaced | Identity provider configuration | |
| 139 | +| `AccessServiceToken` | Namespaced | Service token for M2M auth | |
| 140 | +| `GatewayRule` | Namespaced | Gateway policy rule | |
| 141 | +| `GatewayList` | Namespaced | List for gateway policies | |
| 142 | +| `GatewayConfiguration` | Cluster | Global gateway settings | |
| 143 | +| `DeviceSettingsPolicy` | Cluster | WARP client settings | |
| 144 | +| `DevicePostureRule` | Namespaced | Device posture check | |
| 145 | +| `DNSRecord` | Namespaced | DNS record management | |
| 146 | +| `WARPConnector` | Namespaced | WARP connector deployment | |
| 147 | + |
| 148 | +## Documentation |
| 149 | + |
| 150 | +- [Getting Started Guide](docs/getting-started.md) |
| 151 | +- [API Reference (v1alpha2)](docs/v1alpha2.md) |
| 152 | +- [Migration from v1alpha1](docs/migration/v1alpha2.md) |
| 153 | +- [Examples](docs/examples/) |
| 154 | + |
| 155 | +## Contributing |
| 156 | + |
| 157 | +Contributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md) for details. |
| 158 | + |
| 159 | +## License |
| 160 | + |
| 161 | +This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details. |
59 | 162 |
|
60 | 163 | > **_NOTE_**: This is **NOT** an official operator provided/backed by Cloudflare Inc. It utilizes their [v4 API](https://api.cloudflare.com/) and their [`cloudflared`](https://github.com/cloudflare/cloudflared) to automate setting up of tunnels on Kubernetes. |
0 commit comments