Skip to main content

okustera_database_mongodb (Resource)

Manages an enterprise-grade MongoDB replica set powered by Percona Server for MongoDB on Kubernetes, featuring automated sharding/replica sets, TLS encryption in transit, and Ceph persistent storage.

Example Usage​

Production 3-Node MongoDB Replica Set​

resource "okustera_database_mongodb" "catalog_db" {
name = "product-catalog-mongo"
namespace = "production"
instances = 3
storage_size = "50Gi"
storage_class = "ceph-rbd"
database_name = "catalog"
username = "catalogadmin"
password = var.mongo_password
}

output "mongodb_uri" {
value = okustera_database_mongodb.catalog_db.connection_uri
sensitive = true
}

Schema​

Required​

  • instances (Number) Number of replica set members (1 for standalone, 3 for production HA).
  • name (String, Forces new resource) Unique name of the MongoDB cluster.

Optional​

  • database_name (String) Default application authentication database name. Defaults to admin.
  • namespace (String, Forces new resource) Kubernetes namespace for the database cluster. Defaults to default.
  • password (String, Sensitive) Custom database root password (auto-generated securely if omitted).
  • storage_class (String) Kubernetes StorageClass name. Defaults to ceph-rbd.
  • storage_size (String) Ceph RBD persistent volume size (e.g. 10Gi, 100Gi). Defaults to 10Gi.
  • username (String) Database administrator username. Defaults to mongoadmin.

Read-Only​

  • connection_uri (String, Sensitive) Full MongoDB connection string with credentials.
  • id (String) Unique cluster identifier UUID.
  • primary_endpoint (String) Primary read-write service endpoint hostname.
  • status (String) Cluster health status (e.g. Ready, Creating).

Import​

MongoDB clusters can be imported using <namespace>/<name> or <name>:

terraform import okustera_database_mongodb.example "production/product-catalog-mongo"