Skip to content
Documentation menu

Docs / Reference / Workers and storage

D1Database

D1Database represents a Cloudflare D1 database. Deleting it deletes the database and all of its data, unless the retain deletion policy is set.

API version
kflare.dev/v1alpha1
Scope
Namespaced
Short name
cfd1
Token permission
Account · D1 · 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.

d1database.yaml
apiVersion: kflare.dev/v1alpha1
kind: D1Database
metadata:
  name: example-d1database
  namespace: default
  annotations:
    kflare.dev/deletion-policy: retain
spec:
  accountRef:
    name: my-account
  name: example-db
  # jurisdiction: eu  # one of: eu, fedramp, us
  # primaryLocationHint: wnam  # one of: wnam, enam, weur, eeur, apac, oc

Spec

What you set, with the limits the API server enforces.

FieldDescription
accountRef
objectrequiredimmutable

AccountRef references the CloudflareAccount that owns the D1 database. Immutable after creation.

accountRef.name
string

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: ""

jurisdiction
stringimmutable

Specify the location to restrict the D1 database to run and store data. If this option is present, the location hint is ignored.

One of: eu, fedramp, us

name
stringrequiredimmutable

Name is the database's name in Cloudflare, unique within the account. It cannot change.

Limits: matches ^[a-zA-Z0-9][a-zA-Z0-9_-]*$

primaryLocationHint
stringimmutable

PrimaryLocationHint asks Cloudflare to create the database's primary in this region, if it is available there; without it, Cloudflare picks a region close to kflare's manager. Cloudflare does not report it back, so it takes effect only when kflare creates the database.

One of: wnam, enam, weur, eeur, apac, oc

Rules

Checked across fields when the resource is applied.

  • jurisdiction is immutable
  • primaryLocationHint is immutable

Status

What kflare reports. conditions holds the Ready condition, whose reason says why a resource isn't ready.

FieldDescription
cloudflareMetadata
object

CloudflareMetadata holds identifiers and metadata returned by the Cloudflare API.

cloudflareMetadata.databaseID
string

DatabaseID is the D1 database's identifier, which a Worker's D1 binding names.

cloudflareMetadata.version
string

Version is the D1 backend the database runs on, such as production.

conditions
[]object

Conditions represent the latest available observations of the D1 database state.

kubectl get

The columns kubectl get d1databases prints.

ColumnSource
NAME.spec.name
DATABASE ID.status.cloudflareMetadata.databaseID
READY.status.conditions[?(@.type=="Ready")].status
AGE.metadata.creationTimestamp

Samples

From the repository's config/samples, comments included.

cloudflare_v1alpha1_d1database.yaml
# Generated by kflare-gen from generator/generator.yaml. DO NOT EDIT.
#
# D1Database is the Schema for the d1databases API.
# It represents a Cloudflare D1 database. Deleting it deletes the
# database and all of its data, unless the retain deletion policy is set.
apiVersion: kflare.dev/v1alpha1
kind: D1Database
metadata:
  name: example-d1database
  namespace: default
  annotations:
    # The retain policy keeps the D1 database in Cloudflare when this resource
    # is deleted. Without it, deleting the resource deletes the D1 database.
    kflare.dev/deletion-policy: retain
spec:
  accountRef:
    name: my-account
  # Name is the database's name in Cloudflare, unique within the
  # account. It cannot change.
  name: example-db

On GitHub