cloudflared

by CodeChem

Helm chartv1.0.0App 2022.10.3Verified publisher

CodeChem Cloudflared (Argo Tunnel) Helm Chart

About this chart

Cloudflared (Argo Tunnel)

A tunneling daemon that proxies traffic from the Cloudflare network to your origins. This daemon sits between Cloudflare network and your origin (e.g. a webserver). Cloudflare attracts client requests and sends them to you via this daemon, without requiring you to poke holes on your firewall --- your origin can remain as closed as possible. Extensive documentation can be found in the Cloudflare Tunnel section of the Cloudflare Docs.

TL;DR

helm repo add codechem https://charts.codechem.com
helm install cloudflared codechem/cloudflared

Introduction

Cloudflare Tunnel provides you with a secure way to connect your resources to Cloudflare without a publicly routable IP address. With Tunnel, you do not send traffic to an external IP — instead, a lightweight daemon in your infrastructure (cloudflared) creates outbound-only connections to Cloudflare’s edge. Cloudflare Tunnel can connect HTTP web servers, SSH servers, remote desktops, and other protocols safely to Cloudflare. This way, your origins can serve traffic through Cloudflare without being vulnerable to attacks that bypass Cloudflare.

Prerequisites

  • Kubernetes 1.12+
  • Helm 3.2.0+
  • Argo Tunnel ID generated

Installing the Chart

To install the chart with the release name cloudflared:

helm install cloudflared codechem/cloudflared

The command deploys cloudflared on the Kubernetes cluster in the default configuration. The Parameters section lists the parameters that can be configured during installation.

Tip: List all releases using helm list

Uninstalling the Chart

To uninstall/delete the cloudflared deployment:

helm delete cloudflared

The command removes all the Kubernetes components associated with the chart and deletes the release.

Parameters

Image parameters

NameDescriptionValue
image.repositoryThe Docker repository to pull the image from.cloudflare/cloudflared
image.tagThe image tag to use.2022.10.3
image.imagePullPolicyThe logic of image pulling.IfNotPresent

Deployment parameters

NameDescriptionValue
replicaCountThe number of replicas to deploy.3
tunnelIDThe Argo Tunnel ID you created. Check the configuration section for details.""
auth.accountTagThe Argo tunnel account tag.""
auth.tunnelNameThe Argo tunnel name.""
auth.tunnelSecretThe Argo tunnel secret.""
existingSecretThe name of an existing secret containing the Argo tunnel settings.""
warpRoutingWhether to enable WARP traffic routing to local subnets.false
ingressThe ingress settings to apply. Check the configuration section for examples.[]

Specify each parameter using the --set key=value[,key=value] argument to helm install. For example,

helm install example \
  --set user=example \
  --set password=example \
    codechem/example

Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart. For example,

helm install example -f values.yaml codechem/example

Tip: You can use the default values.yaml

Configuration and installation details

Getting the Argo Tunnel ID (required)

  • Start by downloading and installing the lightweight Cloudflare Tunnel daemon, cloudflared. You can find it here.

  • Once installed, you can use the tunnel login command in cloudflared to obtain a certificate:

cloudflared tunnel login
  • Create the tunnel with:
cloudflared tunnel create example-tunnel
  • Associate your tunnel with a CNAME DNS Record
cloudflared tunnel route dns example-tunnel tunnel.example.com
  • The tunnel configuration can be found in ~/.cloudflared/<TUNNEL_ID>.json. You will need it for creating a secret/configmap when deploying the Cloudflared instance on your cluster.

Now, when you want to create a new subdomain, just point it as a CNAME to the tunnel record, and it will be routed automatically!

For more information, check the official guide.

Setting up the Argo Tunnel ingress options with Traefik

To use the tunnel with Traefik, you need to configure the ingress settings. As cloudflared works with CNAMEs, you want to set a wildcard hostname for the service, and set the origin request setting to be the root domain that you are configuring this for. Also, you need to point the service to the secure port (443) of the Traefik load balancer service. Here is an example configuration:

cloudflared:
  ingress:
    - hostname: "*.example.com"
      service: https://traefik.traefik-system.svc.cluster.local:443
      originRequest:
        originServerName: example.com
    - service: http_status:404

License

Copyright © 2022 CodeChem

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Deploy cloudflared with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has cloudflared 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 chartcloudflared is pinned at v1.0.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