OpenMCF logoOpenMCF

Loading...

Civo Database

Deploys a managed MySQL or PostgreSQL database instance on Civo Cloud with configurable replicas, private network attachment, and firewall integration. The component supports up to four read replicas and exposes connection details as stack outputs for wiring to application workloads.

What Gets Created

When you deploy a CivoDatabase resource, OpenMCF provisions:

  • Managed Database Instance — a civo_database resource running the specified engine (MySQL or PostgreSQL) at the chosen version and size, attached to the target private network
  • Replica Nodes — created only when replicas is greater than 0, adding read replicas to the database cluster (total nodes = 1 primary + replica count)
  • Firewall Attachment — created only when firewallIds is provided, attaches a firewall to control network access to the database instance

Prerequisites

  • Civo credentials configured via environment variables or OpenMCF provider config
  • An existing Civo network in the target region for private connectivity (can be created with CivoVpc)
  • A Civo firewall if restricting access to the database (can be created with CivoFirewall)

Quick Start

Create a file civo-db.yaml:

apiVersion: civo.openmcf.org/v1
kind: CivoDatabase
metadata:
  name: my-db
  labels:
    openmcf.org/provisioner: pulumi
    pulumi.openmcf.org/organization: my-org
    pulumi.openmcf.org/project: my-project
    pulumi.openmcf.org/stack.name: dev.CivoDatabase.my-db
spec:
  dbInstanceName: my-db
  engine: postgres
  engineVersion: "14"
  region: nyc1
  sizeSlug: g3.db.small
  networkId:
    value: network-uuid-here

Deploy:

openmcf apply -f civo-db.yaml

This creates a single-node PostgreSQL 14 instance on a g3.db.small plan in New York, attached to the specified private network.

Configuration Reference

Required Fields

FieldTypeDescriptionValidation
dbInstanceNamestringHuman-readable name for the database instance. Must be unique within the region.Required, max 64 characters
engineenumDatabase engine. Valid values: mysql, postgres.Required
engineVersionstringEngine version (e.g., 8.0 for MySQL, 14 for PostgreSQL). Major version only or major.minor.Required, pattern: ^[0-9]+(\.[0-9]+)?$
regionenumCivo region where the database is created. Valid values: lon1, lon2, fra1, nyc1, phx1, mum1.Required
sizeSlugstringPlan identifier defining CPU, memory, and base storage (e.g., g3.db.small).Required
networkIdStringValueOrRefPrivate network ID for the database instance. Can reference a CivoVpc resource via valueFrom.Required

Optional Fields

FieldTypeDefaultDescription
replicasuint320Number of read replicas. Use 0, 2, or 4 for a total of 1, 3, or 5 nodes. Maximum 4 replicas.
firewallIdsStringValueOrRef[][]Firewall IDs to attach for access control. Can reference CivoFirewall resources via valueFrom. Currently only the first firewall ID is applied.
storageGibuint32—Custom storage size in GiB, overriding the default provided by sizeSlug.
tagsstring[][]Tags for organizational purposes within Civo.

Examples

Single-Node MySQL Instance

A minimal MySQL database for development:

apiVersion: civo.openmcf.org/v1
kind: CivoDatabase
metadata:
  name: dev-mysql
  labels:
    openmcf.org/provisioner: pulumi
    pulumi.openmcf.org/organization: my-org
    pulumi.openmcf.org/project: my-project
    pulumi.openmcf.org/stack.name: dev.CivoDatabase.dev-mysql
spec:
  dbInstanceName: dev-mysql
  engine: mysql
  engineVersion: "8.0"
  region: fra1
  sizeSlug: g3.db.small
  networkId:
    value: network-uuid-here

PostgreSQL with Replicas and Firewall

A PostgreSQL cluster with two read replicas and firewall-controlled access:

apiVersion: civo.openmcf.org/v1
kind: CivoDatabase
metadata:
  name: prod-postgres
  labels:
    openmcf.org/provisioner: pulumi
    pulumi.openmcf.org/organization: my-org
    pulumi.openmcf.org/project: my-project
    pulumi.openmcf.org/stack.name: prod.CivoDatabase.prod-postgres
spec:
  dbInstanceName: prod-postgres
  engine: postgres
  engineVersion: "15"
  region: nyc1
  sizeSlug: g3.db.medium
  replicas: 2
  networkId:
    value: network-uuid-here
  firewallIds:
    - value: firewall-uuid-here
  tags:
    - environment:production
    - team:backend

Using Foreign Key References

Reference OpenMCF-managed CivoVpc and CivoFirewall resources instead of hardcoding IDs:

apiVersion: civo.openmcf.org/v1
kind: CivoDatabase
metadata:
  name: ref-db
  labels:
    openmcf.org/provisioner: pulumi
    pulumi.openmcf.org/organization: my-org
    pulumi.openmcf.org/project: my-project
    pulumi.openmcf.org/stack.name: prod.CivoDatabase.ref-db
spec:
  dbInstanceName: ref-db
  engine: postgres
  engineVersion: "15"
  region: lon1
  sizeSlug: g3.db.large
  replicas: 4
  networkId:
    valueFrom:
      kind: CivoVpc
      name: my-network
      field: status.outputs.network_id
  firewallIds:
    - valueFrom:
        kind: CivoFirewall
        name: db-firewall
        field: status.outputs.firewall_id
  tags:
    - environment:production
    - managed-by:openmcf

Stack Outputs

After deployment, the following outputs are available in status.outputs:

OutputTypeDescription
database_idstringUnique identifier (UUID) of the created database instance
hoststringHostname or IP address of the primary database endpoint
portuint32Network port on which the database is listening
usernamestringUsername for the default database user
password_secret_refstringReference to the secret containing the default user's password
replica_endpointsstring[]Host addresses of replica nodes; empty if no replicas were configured

Related Components

  • CivoVpc — provides the private network for database connectivity
  • CivoFirewall — controls network access to the database instance
  • CivoKubernetesCluster — application workloads that connect to the database
  • CivoDnsRecord — creates DNS records pointing to the database endpoint

Next article

Civo DNS Record

Civo DNS Record Manages individual DNS records within a Civo DNS zone. The component creates a single record of any supported type (A, AAAA, CNAME, MX, TXT, SRV, NS), validates the manifest, and exposes the record ID and fully qualified hostname as stack outputs. What Gets Created When you deploy a CivoDnsRecord resource, OpenMCF provisions: Civo DNS Domain Record --- a DNS record of the specified type attached to an existing Civo DNS zone, created via the civo.DnsDomainRecord Pulumi resource...
Read next article
Presets
2 ready-to-deploy configurationsView presets →