Docs / Reference / DNS
DNSRecord
DNSRecord represents a DNS record within a Cloudflare-managed zone.
- API version
- kflare.dev/v1alpha1
- Scope
- Namespaced
- Short name
- cfrecord
- Token permission
- Zone · DNS · Edit
Example
Every field, with the sample's values. The live lines are the repository's sample, which applies as it is; the commented ones are the other fields, filled from other samples where one sets them. Some exclude each other, so check the rules before you uncomment several.
apiVersion: kflare.dev/v1alpha1
kind: DNSRecord
metadata:
name: example-dnsrecord
namespace: default
annotations:
kflare.dev/deletion-policy: retain
spec:
zoneRef:
name: example-zone
name: www.example.com
type: A
comment: The web server.
content: 192.0.2.1
# data:
# name: _http._tcp
# proto: _tcp
# service: _http
# target: app.example.com
# port: 8080
# weight: 1
# priority: 10
# priority: 10
# proxied: true
# tags:
# - <tags>
# ttl: 1
# tunnelRef:
# name: example-tunnelSpec
What you set, with the limits the API server enforces.
| Field | Description |
|---|---|
commentstring | Comment is an optional free-text annotation for the record. |
contentstring | Content is the DNS record content (e.g. an IP address for A records, a hostname for CNAME/MX). Set exactly one of content, data and tunnelRef: record types such as SRV, LOC and CAA use data instead. Limits: at least 1 character |
dataobject (any fields) | Data holds structured record data for types that require it (SRV, LOC, CAA). The JSON structure must match the Cloudflare API schema for the given record type. Set exactly one of content, data and tunnelRef. Cloudflare derives the record content from it, so content drift is not corrected while data is set. |
namestringrequiredimmutable | Name is the fully-qualified DNS record name (e.g. "www.example.com"). Immutable after creation. Limits: at least 1 character |
priorityinteger | Priority is the record priority, used for MX, SRV and URI records. When unset, kflare leaves the priority Cloudflare chose unchanged. |
proxiedboolean | Proxied controls whether Cloudflare proxies traffic through its network for this record. Only applicable to A, AAAA, and CNAME records. Defaults to false (DNS only), or to true with a tunnelRef, which cannot be unproxied. |
tags[]string | Tags are optional labels attached to the record in Cloudflare. |
ttlinteger | TTL is the time-to-live in seconds: 1 for automatic (the default), or 30-86400. Cloudflare only accepts values below 60 on Enterprise zones, and a proxied record always has an automatic TTL. Limits: at least 1 and at most 86400 Rule: ttl must be 1 (automatic) or between 30 and 86400 |
tunnelRefobject | TunnelRef points the record at a Tunnel in the same namespace: kflare sets its content to the tunnel's hostname, <tunnel ID>.cfargotunnel.com, and corrects it when the tunnel is recreated with a new ID. Only for CNAME records, which are then proxied: a tunnel carries traffic only through Cloudflare's proxy, and only for records in the tunnel's account, so the Tunnel must use the Zone's CloudflareAccount. The Tunnel waits for the records that point at it before it is deleted. |
tunnelRef.namestring | Name of the referent. This field is effectively required, but due to backwards compatibility is allowed to be empty. Instances of this type with an empty value here are almost certainly wrong. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names Default: |
typestringrequiredimmutable | Type is the DNS record type. Immutable after creation. One of: |
zoneRefobjectrequiredimmutable | ZoneRef references the Zone, in the same namespace, the DNS record belongs to. Immutable after creation. |
zoneRef.namestring | Name of the referent. This field is effectively required, but due to backwards compatibility is allowed to be empty. Instances of this type with an empty value here are almost certainly wrong. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names Default: |
Rules
Checked across fields when the resource is applied.
- set exactly one of content, data and tunnelRef
- tunnelRef needs type CNAME
- a record with a tunnelRef must be proxied: an unproxied one resolves to an address the internet cannot reach
- a proxied record takes ttl 1 (automatic): Cloudflare ignores any other
Status
What kflare reports. conditions holds the Ready condition, whose reason says why a resource isn't ready.
| Field | Description |
|---|---|
cloudflareMetadataobject | CloudflareMetadata holds identifiers and metadata returned by the Cloudflare API. |
cloudflareMetadata.proxiableboolean | Proxiable indicates whether this record type supports Cloudflare proxying. |
cloudflareMetadata.recordIDstring | RecordID is the Cloudflare DNS record identifier. |
cloudflareMetadata.zoneIDstring | ZoneID is the Cloudflare zone the DNS record belongs to (denormalized from the Zone status). |
conditions[]object | Conditions represent the latest available observations of the DNS record state. |
kubectl get
The columns kubectl get dnsrecords prints.
| Column | Source |
|---|---|
| RECORD NAME | .spec.name |
| TYPE | .spec.type |
| CONTENT | .spec.content |
| RECORD ID | .status.cloudflareMetadata.recordID |
| READY | .status.conditions[?(@.type=="Ready")].status |
| AGE | .metadata.creationTimestamp |
Samples
From the repository's config/samples, comments included.
# Generated by kflare-gen from generator/generator.yaml. DO NOT EDIT.
#
# DNSRecord is the Schema for the dnsrecords API.
# It represents a DNS record within a Cloudflare-managed zone.
apiVersion: kflare.dev/v1alpha1
kind: DNSRecord
metadata:
name: example-dnsrecord
namespace: default
annotations:
# The retain policy keeps the DNS record in Cloudflare when this resource is
# deleted. Without it, deleting the resource deletes the DNS record.
kflare.dev/deletion-policy: retain
spec:
zoneRef:
name: example-zone
# Name is the fully-qualified DNS record name (e.g. "www.example.com").
# Immutable after creation.
name: www.example.com
# Type is the DNS record type. Immutable after creation.
type: A
# Comment is an optional free-text annotation for the record.
comment: The web server.
# Content is the DNS record content (e.g. an IP address for A records,
# a hostname for CNAME/MX). Set exactly one of content, data and
# tunnelRef: record types such as SRV, LOC and CAA use data instead.
content: 192.0.2.1apiVersion: kflare.dev/v1alpha1
kind: DNSRecord
metadata:
name: www-a-record
namespace: default
annotations:
kflare.dev/deletion-policy: retain
spec:
zoneRef:
name: example-zone # must reference an existing Zone CR in the same namespace
name: www.example.com
type: A
content: "1.2.3.4"
ttl: 1 # 1 = automatic TTL
proxied: trueapiVersion: kflare.dev/v1alpha1
kind: DNSRecord
metadata:
name: mx-record
namespace: default
annotations:
kflare.dev/deletion-policy: retain
spec:
zoneRef:
name: example-zone # must reference an existing Zone CR in the same namespace
name: example.com
type: MX
content: mail.example.com
priority: 10
ttl: 300apiVersion: kflare.dev/v1alpha1
kind: DNSRecord
metadata:
name: srv-record
namespace: default
annotations:
kflare.dev/deletion-policy: retain
spec:
zoneRef:
name: example-zone # must reference an existing Zone CR in the same namespace
name: _http._tcp.example.com
type: SRV
ttl: 300
# SRV records use the data field instead of content.
# The structure matches the Cloudflare API schema for SRV records.
data:
name: _http._tcp
proto: _tcp
service: _http
target: app.example.com
port: 8080
weight: 1
priority: 10apiVersion: kflare.dev/v1alpha1
kind: DNSRecord
metadata:
name: app-tunnel-record
namespace: default
spec:
zoneRef:
name: example-zone # must reference an existing Zone CR in the same namespace
name: app.example.com
type: CNAME
# Points the hostname at the Tunnel (same namespace): kflare writes a proxied
# CNAME to <tunnel ID>.cfargotunnel.com, and follows the tunnel if it is
# recreated with a new ID. The Tunnel must use the Zone's CloudflareAccount.
# The TunnelConfiguration's ingress rule for app.example.com decides where
# the traffic goes.
tunnelRef:
name: example-tunnel