cloudflare-dns-operator

Crates.iocloudflare-dns-operator
lib.rscloudflare-dns-operator
version0.1.8
sourcesrc
created_at2024-10-13 02:57:33.981133
updated_at2024-10-14 05:40:49.510898
descriptionKubernetes operator to manage Cloudflare DNS records
homepagehttps://github.com/hypervideo/cloudflare-dns-operator
repositoryhttps://github.com/hypervideo/cloudflare-dns-operator
max_upload_size
id1407039
size163,467
Robert Krahn (rksm)

documentation

README

cloudflare-dns-operator

Crates.io License

This is a kubernetes operator (custom resource definition + kubernetes controller) to manage cloudflare DNS entries from within kubernetes using the cloudflare API.

Note: This is an unofficial project and not affiliated in any way with cloudflare.

Installation

In your kubernetes cluster install the crds.yaml file and a deployment matching examples/deployment.yaml. Note that you'll need to set the env var CLOUDFLARE_API_TOKEN to a valid cloudflare API token.

This sets up the controller as a deployment. It'll watch for CloudflareDNSRecord resources and create/update/delete DNS records in cloudflare.

You can optionally have the controller check the records by doing DNS lookups from 1.1.1.1. The resolution result will be reflected in the status.pending field of the CloudflareDNSRecord resource. For this to be enabled, set the env var CHECK_DNS_RESOLUTION to a human readable duration like 5m or 1h or 60s.

You can then create a new DNS record like this:

apiVersion: dns.cloudflare.com/v1alpha1
kind: CloudflareDNSRecord
metadata:
  name: my-cloudflare-dns-record
spec:
  name: foo.example.com
  type: A
  ttl: 3600
  content: "1.2.3.4"
  zone:
    name:
      value: example.com
  comment: "Managed by the Cloudflare DNS Operator"
  tags:
    - k8s

You can also automatically expose IPs from LoadBalancer services or external IP services by referencing a service in the content instead of a static IP:

# ...
  content:
    service:
      name: traefik
      namespace: traefik
# ...

The zone can also be set with a secret or configMap reference like this:

# ...
  zone:
    name:
      from:
        secret:
          name: cloudflare-dns-secret
          key: zone-name
# ...

See CloudflareDNSRecordSpec for more details.

License: MPL-2.0

Commit count: 43

cargo fmt