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.
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, ocSpec
What you set, with the limits the API server enforces.
| Field | Description |
|---|---|
accountRefobjectrequiredimmutable | AccountRef references the CloudflareAccount that owns the D1 database. Immutable after creation. |
accountRef.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: |
jurisdictionstringimmutable | 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: |
namestringrequiredimmutable | Name is the database's name in Cloudflare, unique within the account. It cannot change. Limits: matches |
primaryLocationHintstringimmutable | 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: |
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.
| Field | Description |
|---|---|
cloudflareMetadataobject | CloudflareMetadata holds identifiers and metadata returned by the Cloudflare API. |
cloudflareMetadata.databaseIDstring | DatabaseID is the D1 database's identifier, which a Worker's D1 binding names. |
cloudflareMetadata.versionstring | 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.
| Column | Source |
|---|---|
| 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.
# 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