Skip to main content
Version: 3.0.0-alpha (Diátaxis)

Concepts — MySQL

Architecture

MySQL on Hikube is a managed service based on the MariaDB-Operator. Although the operator uses MariaDB (a compatible fork of MySQL), the service is fully compatible with MySQL clients and protocols. Each instance deployed via the MariaDB resource creates a replicated cluster with a primary and replicas for high availability.


Terminology

TermDescription
MariaDBKubernetes resource (apps.cozystack.io/v1alpha1) representing a managed MySQL cluster. The CRD is named MariaDB because the service relies on MariaDB-Operator.
PrimaryMain node that accepts reads and writes.
ReplicaRead-only node, synchronized from the primary via binlog replication.
MariaDB-OperatorKubernetes operator that manages deployment, replication, failover, and backups.
ResticBackup tool used to create encrypted snapshots to S3 storage.
SwitchoverPlanned switch of the primary role to another node in the cluster.
resourcesPresetPredefined resource profile (nano to 2xlarge).

Replication and high availability

The MySQL cluster uses MariaDB's binlog replication:

  1. The primary writes all changes to the binary log
  2. The replicas consume the binlog and apply the changes
  3. In case of failure of the primary, the operator automatically promotes a replica

Manual switchover

You can switch the primary to another node for maintenance:

kubectl edit mariadb <instance-name>
# Modify spec.replication.primary.podIndex
warning

Switching the primary causes a brief write interruption. Reads remain available through replicas.


Backup

MySQL on Hikube uses Restic for backups:

  • Snapshots are encrypted with a Restic password
  • Stored in an S3-compatible bucket (Hikube Object Storage, AWS S3, etc.)
  • The retention strategy (cleanupStrategy) controls the retention duration
ParameterDescription
backup.scheduleCron schedule (e.g., 0 2 * * *)
backup.cleanupStrategyRestic retention options (e.g., --keep-last=3 --keep-daily=7)
backup.resticPasswordBackup encryption password
backup.s3*S3 credentials and bucket
tip

Regularly test the restore procedure. An untested backup does not guarantee a successful restore.


User and database management

The manifest allows declaring:

  • Users: name, password, connection limit (maxUserConnections)
  • Databases: name and role assignment
  • Roles: admin (full read/write), readonly (SELECT only)

A root password is automatically generated by the operator and stored in the Secret <instance>-credentials.


Resource presets

PresetCPUMemory
nano250m128Mi
micro500m256Mi
small1512Mi
medium11Gi
large22Gi
xlarge44Gi
2xlarge88Gi
warning

If the resources field (explicit CPU/memory) is set, resourcesPreset is ignored.


Limits and quotas

ParameterValue
Max replicasDepending on tenant quota
Storage size (size)Variable (in Gi)
maxUserConnectionsConfigurable per user (0 = unlimited)

Further reading