A complete setup of a MariaDB Galera cluster for OpenStack is illustrated in the following image:
MariaDB server pods are running a Galera multi-master cluster. Clients
requests are forwarded by the Kubernetes mariadb
service to the
mariadb-server
pod that has the primary
label. Other pods from
the mariadb-server
StatefulSet have the backup
label. Labels are
managed by the mariadb-controller
pod.
The MariaDB controller periodically checks the readiness of the
mariadb-server
pods and sets the primary
label to it if the following
requirements are met:
The primary
label has not already been set on the pod.
The pod is in the ready state.
The pod is not being terminated.
The pod name has the lowest integer suffix among other ready pods in
the StatefulSet. For example, between mariadb-server-1
and
mariadb-server-2
, the pod with the mariadb-server-1
name is
preferred.
Otherwise, the MariaDB controller sets the backup
label. This means that
all SQL requests are passed only to one node while other two nodes are in
the backup state and replicate the state from the primary node.
The MariaDB clients are connecting to the mariadb
service.