Get Started

Get started with cloudflare-operator

This tutorial shows you how to get started with using cloudflare-operator and create a sample DNS record.

Before you begin

The following prerequisites are required to complete this tutorial:

  • A Kubernetes cluster with cloudflare-operator installed (follow the installation guide)
  • A Cloudflare account

Create Cloudflare API token

The token can be created by following this guide.

The following permissions are required:

  • Zone:Zone:Read
  • Zone:DNS:Edit

Configure the following Zone resources:

  • Include:All zones

or, if you want to limit the zones to which the token has access:

  • Include:Specific zone:example.com

The summary should look similar to this:

All zones - Zone:Read, DNS:Edit

Configure Cloudflare account

Create a secret with the previously created Cloudflare API token.

---
apiVersion: v1
kind: Secret
type: Opaque
metadata:
  name: cloudflare-api-token
  namespace: cloudflare-operator
stringData:
  apiToken: 1234

Next, create an account object:

---
apiVersion: cloudflare-operator.io/v1
kind: Account
metadata:
  name: account-sample
spec:
  apiToken:
    secretRef:
      name: cloudflare-api-token
      namespace: cloudflare-operator

Check if the account is ready:

kubectl get accounts.cloudflare-operator.io

This should output the following:

NAME             READY
account-sample   True
kubectl get zones.cloudflare-operator.io
NAME          ZONE NAME      ID                                 READY
example-com   example.com    12345678901234567890123456789012   True

Create a DNS record

Now, we can create our first DNS record:

---
apiVersion: cloudflare-operator.io/v1
kind: DNSRecord
metadata:
  name: example-com
  namespace: cloudflare-operator
spec:
  name: example.com
  type: A
  content: 69.42.0.69
  proxied: true
  ttl: 1
  interval: 5m0s

Check the status of the DNS record:

kubectl get dnsrecords.cloudflare-operator.io --namespace cloudflare-operator
NAME            RECORD NAME     TYPE    READY
example-com     example.com     A       True
Last modified August 14, 2023: fix: use correct interval format (1009d41)