Skip to content

Database

Usage example

Prerequisites

  • A Kubernetes cluster with the operator installed using helm, kubectl or kind (for local development).
  • A Kubernetes Secret with an Aiven authentication token.
apiVersion: aiven.io/v1alpha1
kind: PostgreSQL
metadata:
  name: my-pg
spec:
  authSecretRef:
    name: aiven-token
    key: token

  project: aiven-project-name
  cloudName: google-europe-west1
  plan: startup-4

---

apiVersion: aiven.io/v1alpha1
kind: Database
metadata:
  name: my-db
spec:
  authSecretRef:
    name: aiven-token
    key: token

  project: aiven-project-name
  serviceName: my-pg

  # Database name will default to the value of `metadata.name` if `databaseName` is not specified.
  # Use the `databaseName` field if the desired database name contains underscores.
  databaseName: my_db_name

  lcCtype: en_US.UTF-8
  lcCollate: en_US.UTF-8

Apply the resource with:

kubectl apply -f example.yaml

Verify the newly created Database:

kubectl get databases my-db

The output is similar to the following:

Name     Project               Service Name    
my-db    aiven-project-name    my-pg           


Database

Database is the Schema for the databases API.

Required

  • apiVersion (string). Value aiven.io/v1alpha1.
  • kind (string). Value Database.
  • metadata (object). Data that identifies the object, including a name string and optional namespace.
  • spec (object). DatabaseSpec defines the desired state of Database. See below for nested schema.

spec

Appears on Database.

DatabaseSpec defines the desired state of Database.

Required

  • project (string, Immutable, Pattern: ^[a-zA-Z0-9_-]+$, MaxLength: 63). Identifies the project this resource belongs to.
  • serviceName (string, Immutable, Pattern: ^[a-z][-a-z0-9]+$, MaxLength: 63). Specifies the name of the service that this resource belongs to.

Optional

  • authSecretRef (object). Authentication reference to Aiven token in a secret. See below for nested schema.
  • databaseName (string, Immutable, Pattern: ^[a-zA-Z0-9_][a-zA-Z0-9_-]{0,39}$, MaxLength: 40). DatabaseName is the name of the database to be created.
  • lcCollate (string, Immutable, MaxLength: 128). Default string sort order (LC_COLLATE) of the database. Default value: en_US.UTF-8.
  • lcCtype (string, Immutable, MaxLength: 128). Default character classification (LC_CTYPE) of the database. Default value: en_US.UTF-8.
  • terminationProtection (boolean). It is a Kubernetes side deletion protections, which prevents the database from being deleted by Kubernetes. It is recommended to enable this for any production databases containing critical data.

authSecretRef

Appears on spec.

Authentication reference to Aiven token in a secret.

Required

  • key (string, MinLength: 1).
  • name (string, MinLength: 1).