Get Started
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.
The key in the secret must be named
apiToken
.
---
apiVersion: v1
kind: Secret
type: Opaque
metadata:
name: cloudflare-api-token
namespace: cloudflare-operator
stringData:
apiToken: 1234 # change this to your Cloudflare API token
Or alternatively, you can use the following command:
kubectl create secret generic cloudflare-api-token --namespace=cloudflare-operator --from-literal=apiToken=<YOUR-CLOUDFLARE-API-TOKEN>
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
Note that after a successful installation and configuration, if the prune option is enabled, cloudflare-operator will delete ALL DNS records in EVERY ZONE for which you have created a Zone object!
It is therefore highly recommended to export your existing DNS records first! You can migrate all your DNS records to cloudflare-operator by following this guide.
Next, create a zone object:
---
apiVersion: cloudflare-operator.io/v1
kind: Zone
metadata:
name: example-com
spec:
name: example.com
prune: false # default value
Verify that the zone is ready:
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