Skip to content

Commit 39740a4

Browse files
authored
SYS-664 mariadb-galera 12.0.2 (#231)
1 parent 01ecdfe commit 39740a4

14 files changed

Lines changed: 165 additions & 162 deletions

File tree

ansible/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
ansible==12.0.0
22
ansible-lint==25.9.1
3-
pip==25.2
3+
pip==25.3

images/mariadb-galera/Dockerfile

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
FROM python:3.8.10-slim-buster
2-
MAINTAINER Rich Braun "docker@instantlinux.net"
1+
FROM mariadb:12.0.2
32
ARG BUILD_DATE
43
ARG VCS_REF
5-
LABEL org.label-schema.build-date=$BUILD_DATE \
4+
LABEL org.opencontainers.image.authors="Rich Braun docker@instantlinux.net" \
5+
org.label-schema.build-date=$BUILD_DATE \
66
org.label-schema.license=GPL-2.0 \
77
org.label-schema.name=mariadb-galera \
88
org.label-schema.vcs-ref=$VCS_REF \
@@ -12,41 +12,26 @@ ENV DEBIAN_FRONTEND=noninteractive \
1212
CLUSTER_NAME=cluster01 \
1313
CLUSTER_SIZE=3 \
1414
DISCOVERY_SERVICE=etcd:2379 \
15-
ROOT_PASSWORD_SECRET=mysql-root-password \
15+
ROOT_SECNAME=mysql-root-password \
1616
TTL=10 \
17-
TZ=UTC \
18-
SST_AUTH_SECRET=sst-auth-password
19-
20-
ARG MARIADB_MAJOR=10.4
21-
ARG MARIADB_VERSION=10.4.20
22-
ARG APT_KEY=F1656F24C74CD1D8
23-
ARG DEB_REL=buster
17+
TZ=UTC
2418
ARG UID=212
2519
ARG GID=212
2620

2721
COPY requirements/ /root/
28-
29-
RUN apt-get -yq update && apt-get install -yq gnupg && \
30-
apt-key adv --recv-keys --keyserver keyserver.ubuntu.com $APT_KEY && \
31-
echo "deb [arch=amd64] \
32-
http://nyc2.mirrors.digitalocean.com/mariadb/repo/$MARIADB_MAJOR/debian $DEB_REL main" \
33-
> /etc/apt/sources.list.d/mariadb.list && \
34-
groupadd -g $GID mysql && \
35-
useradd -u $UID -g $GID -s /bin/false -c "MariaDB" -d /none mysql && \
36-
apt-get -yq update && apt-get -yq install --no-install-recommends \
37-
curl iputils-ping jq mariadb-server=1:$MARIADB_VERSION+maria~$DEB_REL \
38-
mariadb-backup=1:$MARIADB_MAJOR_$MARIADB_VERSION+maria~$DEB_REL \
39-
mariadb-client=1:$MARIADB_MAJOR_$MARIADB_VERSION+maria~$DEB_REL \
40-
net-tools netcat procps && \
41-
apt-get clean && rm -fr /var/log/* /var/lib/mysql/* && \
42-
rm -fr /root/.cache /usr/share/zoneinfo/leap-seconds.list
43-
RUN pip install -r /root/common.txt && \
22+
RUN groupmod -g $GID mysql && \
23+
usermod -u $UID -s /bin/false -c "MariaDB" -d /none mysql && \
24+
apt -yq update && apt -yq install --no-install-recommends \
25+
curl iputils-ping jq net-tools netcat-openbsd procps \
26+
python3 python3-pip python3-etcd3 && \
27+
apt-get clean && rm -fr /var/log/* /var/lib/mysql/* \
28+
/var/lib/apt/lists /var/cache/debconf/*old /root/.cache
29+
RUN pip install -r /root/common.txt --break-system-packages && \
4430
echo "dash dash/sh boolean false" | debconf-set-selections && \
4531
dpkg-reconfigure dash || true
4632

4733
EXPOSE 3306 4444 4567/udp 4567 4568
4834
VOLUME /var/lib/mysql
49-
5035
HEALTHCHECK --interval=10s --timeout=3s --retries=30 \
5136
CMD /bin/sh /usr/local/bin/healthcheck.sh || exit 1
5237

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
FROM python:3.7.0-alpine3.8
2-
MAINTAINER Rich Braun "docker@instantlinux.net"
1+
# Experimental - this "almost" works but SST transfers fail, apparently
2+
# due to issues with the mariadb-backup script distributed with alpine;
3+
# abandoned this in favor of the image distributed by MariaDB maintainers
4+
5+
FROM python:3.14.0-alpine3.22
36
ARG BUILD_DATE
47
ARG VCS_REF
5-
LABEL org.label-schema.build-date=$BUILD_DATE \
8+
LABEL org.opencontainers.image.authors="Rich Braun docker@instantlinux.net" \
9+
org.label-schema.build-date=$BUILD_DATE \
610
org.label-schema.license=GPL-2.0 \
711
org.label-schema.name=mariadb-galera \
812
org.label-schema.vcs-ref=$VCS_REF \
@@ -11,27 +15,25 @@ LABEL org.label-schema.build-date=$BUILD_DATE \
1115
ENV CLUSTER_NAME=cluster01 \
1216
CLUSTER_SIZE=3 \
1317
DISCOVERY_SERVICE=etcd:2379 \
14-
ROOT_PASSWORD_SECRET=mysql-root-password \
18+
PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python \
19+
ROOT_SECNAME=mysql-root-password \
1520
TTL=10 \
1621
TZ=UTC \
17-
SST_PASSWORD= \
18-
SST_SECRET=sst-auth-password
22+
SST_SECNAME=sst-auth-password
1923

20-
ARG MARIADB_MAJOR=10.3
21-
ARG MARIADB_VERSION=10.3.9-r2
24+
ARG MARIADB_MAJOR=11.4
25+
ARG MARIADB_VERSION=11.4.8-r0
2226
ARG UID=212
2327
ARG GID=212
2428

2529
COPY requirements/ /root/
2630

27-
RUN echo '@edge http://dl-cdn.alpinelinux.org/alpine/edge/main' \
28-
>>/etc/apk/repositories && \
29-
addgroup -g $GID mysql && \
31+
RUN addgroup -g $GID mysql && \
3032
adduser -u $UID -G mysql -s /bin/false -g "MariaDB" -h /none -D mysql && \
3133
apk add --update --no-cache \
32-
curl jq mariadb@edge=$MARIADB_VERSION \
33-
mariadb-backup@edge=$MARIADB_VERSION \
34-
mariadb-client@edge=$MARIADB_VERSION net-tools socat && \
34+
bash curl galera jq mariadb=$MARIADB_VERSION \
35+
mariadb-backup=$MARIADB_VERSION \
36+
mariadb-client=$MARIADB_VERSION net-tools pv socat && \
3537
pip install -r /root/common.txt && \
3638
ln -s /usr/bin/mysqld /usr/sbin && \
3739
rm -fr /var/log/* /var/lib/mysql/*
@@ -44,6 +46,7 @@ HEALTHCHECK --interval=10s --timeout=3s --retries=30 \
4446

4547
COPY wsrep.cnf my.cnf /etc/
4648
COPY src/entrypoint.py src/healthcheck.sh /usr/local/bin/
49+
COPY wsrep_sst_mariabackup /usr/bin/
4750
ENTRYPOINT ["/usr/local/bin/entrypoint.py"]
4851

4952
# TODO: fix healthcheck.sh to handle long-duration bootstrap

images/mariadb-galera/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ test_requirements: python_env
2727

2828
$(VDIR)/bin/python:
2929
@echo "Creating virtual environment"
30-
virtualenv --system-site-packages $(VDIR)
30+
python3 -m venv --system-site-packages $(VDIR)
3131

3232
pytest: test_requirements
3333
@echo "Running pytest unit tests"

images/mariadb-galera/README.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
## mariadb-galera
22
[![](https://img.shields.io/docker/v/instantlinux/mariadb-galera?sort=date)](https://hub.docker.com/r/instantlinux/mariadb-galera/tags "Version badge") [![](https://img.shields.io/docker/image-size/instantlinux/mariadb-galera?sort=date)](https://github.com/instantlinux/docker-tools/tree/main/images/mariadb-galera "Image badge") [![](https://img.shields.io/badge/dockerfile-latest-blue)](https://gitlab.com/instantlinux/docker-tools/-/blob/main/images/mariadb-galera/Dockerfile "dockerfile")
33

4-
MariaDB 10.4 with automatic cluster generation under kubernetes / swarm using named volumes for data persistence. This has robust bootstrap logic based on MariaDB / Galera documentation for automated cluster create / join operations.
4+
MariaDB 12.x with automatic cluster generation under kubernetes / swarm using named volumes for data persistence. This has robust bootstrap logic based on MariaDB / Galera documentation for automated cluster create / join operations. Requires an etcd instance for sharing instance-health data across the cluster.
55

66
### Usage - kubernetes
77

8-
Define the following dependencies before launching the cluster: passwords for root and SST, network load balancer, and a dedicated etcd key-value store. Here's how:
8+
Define the following dependencies before launching the cluster: password for root, network load balancer, and a dedicated etcd key-value store. Here's how:
99

1010
Create a random root password:
1111
```
@@ -25,7 +25,7 @@ EOT
2525
sekret enc /dev/shm/new.yaml >secrets/$SECRET
2626
rm /dev/shm/new.yaml
2727
```
28-
You can use a tool like [sops](https://github.com/mozilla/sops) or [sekret](https://github.com/nownabe/sekret) to generate the secrets file. Do the same for an sst-auth-password.
28+
You can use a tool like [sops](https://github.com/mozilla/sops) or [sekret](https://github.com/nownabe/sekret) to generate the secrets file.
2929

3030
Set any local my.cnf values in files under a volume mount for
3131
/etc/mysql/my.cnf.d (mapped as $ADMIN_PATH/mariadb/etc/). Use
@@ -90,9 +90,19 @@ cd docker-tools/k8s
9090
make db00
9191
~~~
9292

93+
### Restarting
94+
95+
When taking the database down, wait for all pods to stop, and then clear etcd entries for the cluster:
96+
```
97+
CLUSTER=db00
98+
ETCD_HOST=10.101.1.19
99+
etcdctl --endpoints=$ETCD_HOST:2379 del --prefix /galera/$CLUSTER
100+
```
101+
Then launch with the helm chart or docker-compose.
102+
93103
### Usage - swarm
94104

95-
This was originally developed under docker Swarm. A [docker-compose](https://github.com/instantlinux/docker-tools/blob/main/images/mariadb-galera/docker.compose) file is a legacy of that original work. Before stack-deploying it, invoke _docker secret create_ to generate the two secrets _mysql-root-password_ and _sst-auth-password-, and define an ADMIN_PATH environment variable pointing to your my.cnf (it has to be in the same location on each docker node).
105+
This was originally developed under docker Swarm. A [docker-compose](https://github.com/instantlinux/docker-tools/blob/main/images/mariadb-galera/docker.compose) file is a legacy of that original work. Before stack-deploying it, invoke _docker secret create_ to generate the secret _mysql-root-password_, and define an ADMIN_PATH environment variable pointing to your my.cnf (it has to be in the same location on each docker node).
96106

97107
### Variables
98108

@@ -102,11 +112,11 @@ This was originally developed under docker Swarm. A [docker-compose](https://git
102112
| CLUSTER_NAME | cluster01 | cluster name |
103113
| CLUSTER_SIZE | 3 | expected number of nodes |
104114
| DISCOVERY_SERVICE | etcd:2379 | etcd host list, e.g. etcd1:2379,etcd2:2379 |
115+
| LOG_LEVEL | info | set to debug for additional logging |
105116
| REINSTALL_OK | | set to any value to enable reinstall over old volume |
106-
| ROOT_PASSWORD_SECRET | mysql-root-password | name of secret for password |
117+
| ROOT_SECNAME | mysql-root-password | name of secret for password |
107118
| TTL | 10 | longevity (in seconds) of keys posted to etcd |
108119
| TZ | UTC | timezone |
109-
| SST_AUTH_SECRET | sst-auth-password | name of secret for password |
110120

111121
### Notes
112122

@@ -129,6 +139,8 @@ configuration. It requires a stable etcd configuration for node
129139
discovery and master election at restart. A single instance can
130140
be invoked without HA resources using kubernetes-single.yaml.
131141

142+
There is no supported etcd3 library for python3 (as of Oct 2025). For now, this is using python-etcd3 0.12.0, last updated in 2020, with PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION set for compatibility.
143+
132144
### Credits
133145

134146
Thanks to ashraf-s9s of severalnines for the healthcheck script.

images/mariadb-galera/helm/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ sources:
77
- https://github.com/MariaDB/server
88
- https://github.com/MariaDB/galera
99
type: application
10-
version: 0.1.0
11-
appVersion: "10.4.20"
10+
version: 0.1.1
11+
appVersion: "12.0.2"
1212
dependencies:
1313
- name: chartlib
1414
version: 0.1.8

images/mariadb-galera/helm/templates/configmap.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ data:
5757
# * InnoDB
5858
#
5959
innodb_data_file_path = ibdata1:10M:autoextend
60-
innodb_buffer_pool_instances = {{ .Values.innodb_buffer_pool_instances }}
6160
innodb_buffer_pool_size = {{ .Values.innodb_buffer_pool_size }}
6261
innodb_log_file_size = {{ .Values.innodb_log_file_size }}
6362

images/mariadb-galera/helm/values.yaml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ ipReadOnly: 10.101.1.101
33
nodePort: 30306
44
character_set_server: utf8
55
ft_min_word_len: 3
6-
innodb_buffer_pool_instances: 1
76
innodb_buffer_pool_size: 1024M
87
innodb_log_file_size: 32M
98
interactive_timeout: 28800
@@ -26,8 +25,9 @@ statefulset:
2625
containerPorts: [ containerPort: 3306 ]
2726
env:
2827
cluster_name: mariadb
29-
discovery_service: "10.101.1.19:2379"
3028
cluster_size: 3
29+
discovery_service: "10.101.1.19:2379"
30+
log_level: info
3131
replicas: 3
3232
resources:
3333
limits:
@@ -48,19 +48,13 @@ volumeMounts:
4848
- name: mysql-root-password
4949
mountPath: /run/secrets/mysql-root-password
5050
subPath: mysql-root-password
51-
- name: sst-auth-password
52-
mountPath: /run/secrets/sst-auth-password
53-
subPath: sst-auth-password
5451
volumes:
5552
- name: etc
5653
configMap:
5754
name: mariadb-galera
5855
- name: mysql-root-password
5956
secret:
6057
secretName: mysql-root-password
61-
- name: sst-auth-password
62-
secret:
63-
secretName: sst-auth-password
6458
volumeClaimTemplates:
6559
- metadata:
6660
name: data
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/sh
2-
TAG=$(grep "ARG .*_VERSION" Dockerfile | cut -d= -f 2)
2+
TAG=$(grep "FROM mariadb:" Dockerfile | cut -d: -f 2)
33
echo "--tag $DOCKER_REPO:$TAG"

images/mariadb-galera/my.cnf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ socket = /dev/shm/mysqld.sock
1010
default_storage_engine = InnoDB
1111
query_cache_size = 0
1212
query_cache_type = 0
13+
slave_connections_needed_for_purge = 0
1314

1415
innodb_flush_log_at_trx_commit = 0
1516
innodb_flush_method = O_DIRECT

0 commit comments

Comments
 (0)