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
Note that after a successful installation and configuration, cloudflare-operator will delete ALL DNS records in EVERY ZONE to which the API token has access!
It is therefore highly recommended to export your existing DNS records first!
Create Cloudflare API token
The token can be created by following this guide.
The following permissions are required:
Configure the following
or, if you want to limit the zones to which the token has access:
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.
The key in the secret must be named
--- 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
Did you export your existing DNS records?
After creating the account, cloudflare-operator will delete ALL DNS records in EVERY ZONE to which the API token has access!
This is your last chance to export your existing DNS records!
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: 126.96.36.199 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