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
Attention! ⚠️
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! You can migrate all your DNS records to cloudflare-operator by following this guide.
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! You can migrate all your DNS records to cloudflare-operator by following this guide.
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.
Note
The key in the secret must be named
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
Next, create an account object:
⚠️ BE CAREFUL! ⚠️
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! Also, don’t forget to migrate your DNS records to cloudflare-operator before creating the account object!
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! Also, don’t forget to migrate your DNS records to cloudflare-operator before creating the 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 September 27, 2024: feat: add migration guide (2bd8ff6)