DBaaS Manager
The DBaaS Manager creates Thalassa Cloud PostgreSQL resources from Kubernetes. You declare the database in the cluster. The controller reconciles that declaration with the DBaaS API.
Warning
This controller is in beta. The API may change. End-to-end tests do not cover every resource.
The controller uses the cluster identity and workload identity federation. It does not store a long-lived Thalassa credential in environment variables when you use token exchange.
Custom resources
The API group is dbaas.controllers.thalassa.cloud/v1.
| Kind | Purpose |
|---|---|
PostgresCluster | Creates a PostgreSQL cluster, including version, size, storage, subnet, and backup schedules. |
PostgresDatabase | Creates a database on a cluster. |
PostgresRole | Creates a login role. The controller can write a connection Secret. |
PostgresGrant | Grants read access, write access, or both, on a database to a role. |
DbObjectStore | Creates the backup object store used by cluster backups. |
Subnet and security group fields take Thalassa identities. The controller does not use Kubernetes custom resources for those objects.
When spec.subnet is empty, the controller uses its configured default subnet. Set spec.subnet.identity on the cluster when you want a specific subnet. Set security groups with spec.securityGroups[].identity.
spec.onDelete defaults to Delete. Deleting the PostgresCluster object then deletes the Thalassa cluster. Orphan leaves the Thalassa cluster in place. BackupAndDelete takes a final backup, waits for that backup, and then deletes the cluster. Set spec.deleteProtection: true on clusters you must keep.
spec.exposeService defaults to true. The controller creates a Service on port 5432 (read-write) and port 5433 (read-only).
Before you install
- A Kubernetes cluster with Thalassa API access. On a Thalassa cluster, the identity provider must already exist.
- Helm 3 and permission to pull charts from
oci://ghcr.io/thalassa-cloud/charts/. - The
tcloudCLI, with permission to bootstrap workload identity. - A subnet identity, a PostgreSQL version, an instance type, and a volume type class ID for each cluster.
Bind the controller service account to dbaas:DbaasManager. That policy is the intended binding for this controller. It can create and delete database clusters, so limit who can create these custom resources in the cluster.
Install
Bootstrap the controller service account once.
export ORGANISATION_ID="<organisation-id>"
export CLUSTER_ID="<cluster-id>"
tcloud iam workload-identity-federation bootstrap kubernetes \
--cluster "$CLUSTER_ID" \
--namespace thalassa-dbaas-manager \
--service-account thalassa-dbaas-manager \
--policy dbaas:DbaasManagerCopy the Thalassa service account ID from the command output.
Install the CRDs, then the controller. Replace <version> with the chart release you want to run.
export THALASSA_SERVICE_ACCOUNT_ID="<thalassa-service-account-id>"
helm upgrade --install thalassa-dbaas-manager-crds \
oci://ghcr.io/thalassa-cloud/charts/thalassa-dbaas-manager-crds:<version> \
--namespace thalassa-dbaas-manager \
--create-namespace
helm upgrade --install thalassa-dbaas-manager \
oci://ghcr.io/thalassa-cloud/charts/thalassa-dbaas-manager:<version> \
--namespace thalassa-dbaas-manager \
--create-namespace \
--set thalassa.organisation="$ORGANISATION_ID" \
--set thalassa.tokenExchange.serviceAccountId="$THALASSA_SERVICE_ACCOUNT_ID" \
--set enableServiceMonitor=falseThe chart uses token exchange by default. It mounts a projected service account token with audience https://api.thalassa.cloud. Personal access tokens and OAuth2 client credentials are described in the chart README in the source repository.
By default, a PostgresRole password Secret must live in the same namespace as the role. Cross-namespace Secret references require allowAllNamespacesSecretRef: true. Leave that value false unless the cluster must allow it.
Example
apiVersion: dbaas.controllers.thalassa.cloud/v1
kind: PostgresCluster
metadata:
name: app-db
namespace: default
spec:
postgresVersion: "16"
instanceType:
id: "<instance-type-id>"
storageGB: 20
volumeTypeClassId: "<volume-type-class-id>"
instances: 2
subnet:
identity: "<subnet-id>"
deleteProtection: true
---
apiVersion: dbaas.controllers.thalassa.cloud/v1
kind: PostgresDatabase
metadata:
name: app
namespace: default
spec:
clusterRef:
name: app-db
name: app
owner: app
---
apiVersion: dbaas.controllers.thalassa.cloud/v1
kind: PostgresRole
metadata:
name: app
namespace: default
spec:
clusterRef:
name: app-db
name: app
login: true
writeConnectionSecretToRef:
name: app-db-connectionWhen writeConnectionSecretToRef is set, generatePassword defaults to true. The controller generates a password and writes connection keys into that Secret.
Create a DbObjectStore and set spec.dbObjectStore on the cluster when the cluster must send backups to Thalassa. See Backups.
spec.restore creates the cluster from a backup. That block is immutable after Thalassa has created the cluster. You cannot set spec.initDb and spec.restore on the same cluster.
Related documentation
- DBaaS — Managed PostgreSQL on Thalassa Cloud
- High availability — Replicas and failover
- Workload identity for Kubernetes — Projected tokens and token exchange
- DBaaS Manager source — Chart values and the API reference