okustera_database_mysql (Resource)
Manages a high-availability MySQL 8.0 cluster with automated replication (InnoDB Cluster), Ceph RBD persistent storage, backup scheduling, and pod anti-affinity.
Example Usage
Production 3-Node MySQL InnoDB Cluster
resource "okustera_database_mysql" "app_db" {
name = "ecommerce-mysql"
namespace = "production"
instances = 3
storage_size = "100Gi"
storage_class = "ceph-rbd"
database_name = "ecommerce"
username = "ecomadmin"
password = var.db_password
}
output "mysql_rw_endpoint" {
value = okustera_database_mysql.app_db.primary_endpoint
}
Schema
Required
instances(Number) Number of database instances/replicas (1 for standalone development, 3 for InnoDB Cluster HA).name(String, Forces new resource) Unique name of the MySQL cluster.
Optional
database_name(String) Default application database schema name. Defaults toapp_db.namespace(String, Forces new resource) Kubernetes namespace for the database cluster. Defaults todefault.password(String, Sensitive) Custom database root password (auto-generated securely if omitted).storage_class(String) Kubernetes StorageClass name. Defaults toceph-rbd.storage_size(String) Ceph RBD persistent volume size (e.g.10Gi,50Gi). Defaults to10Gi.username(String) Database administrator username. Defaults tomysqladmin.
Read-Only
connection_uri(String, Sensitive) Full MySQL 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
MySQL clusters can be imported using <namespace>/<name> or <name>:
terraform import okustera_database_mysql.example "production/ecommerce-mysql"