Skip to content

Commit 72bfea0

Browse files
committed
galera: support mariabackup SST method
Make the SST method configurable in the galera custom resource, and allow both rsync and mariabackup methods. Mariabackup requires a database user's credentials to operate, so reuse the root db user for the time being. The ability to inject passwords in template galera config files has been implemented. We benefit from that to generate the usual .my.cnf config file for mysql CLI running in the galera container.
1 parent 21af8a1 commit 72bfea0

File tree

12 files changed

+270
-144
lines changed

12 files changed

+270
-144
lines changed

api/bases/mariadb.openstack.org_galeras.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ spec:
7878
secret:
7979
description: Name of the secret to look for password keys
8080
type: string
81+
sst:
82+
default: rsync
83+
description: Snapshot State Transfer method to use for full node synchronization
84+
enum:
85+
- rsync
86+
- mariabackup
87+
type: string
8188
storageClass:
8289
description: Storage class to host the mariadb databases
8390
type: string

api/v1beta1/galera_types.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const (
2626
CustomServiceConfigFile = "galera_custom.cnf.in"
2727
)
2828

29+
2930
// GaleraSpec defines the desired state of Galera
3031
type GaleraSpec struct {
3132
// Name of the secret to look for password keys
@@ -56,8 +57,20 @@ type GaleraSpec struct {
5657
// +kubebuilder:validation:Optional
5758
// Adoption configuration
5859
AdoptionRedirect AdoptionRedirectSpec `json:"adoptionRedirect"`
60+
// +kubebuilder:validation:Optional
61+
// +kubebuilder:default=rsync
62+
// +kubebuilder:validation:Enum=rsync;mariabackup
63+
// Snapshot State Transfer method to use for full node synchronization
64+
SST GaleraSST `json:"sst"`
5965
}
6066

67+
// Supported SST type
68+
type GaleraSST string
69+
const (
70+
RSync GaleraSST = "rsync"
71+
MariaBackup = "mariabackup"
72+
)
73+
6174
// GaleraAttributes holds startup information for a Galera host
6275
type GaleraAttributes struct {
6376
// Last recorded replication sequence number in the DB

config/crd/bases/mariadb.openstack.org_galeras.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ spec:
7878
secret:
7979
description: Name of the secret to look for password keys
8080
type: string
81+
sst:
82+
default: rsync
83+
description: Snapshot State Transfer method to use for full node synchronization
84+
enum:
85+
- rsync
86+
- mariabackup
87+
type: string
8188
storageClass:
8289
description: Storage class to host the mariadb databases
8390
type: string
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: mariadb.openstack.org/v1beta1
2+
kind: Galera
3+
metadata:
4+
name: openstack
5+
spec:
6+
secret: osp-secret
7+
storageClass: local-storage
8+
storageRequest: 500M
9+
replicas: 3
10+
sst: mariabackup

pkg/mariadb/statefulset.go

Lines changed: 3 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -53,25 +53,7 @@ func StatefulSet(g *mariadbv1.Galera) *appsv1.StatefulSet {
5353
},
5454
},
5555
}},
56-
VolumeMounts: []corev1.VolumeMount{{
57-
MountPath: "/var/lib/mysql",
58-
Name: "mysql-db",
59-
}, {
60-
MountPath: "/var/lib/config-data",
61-
ReadOnly: true,
62-
Name: "config-data",
63-
}, {
64-
MountPath: "/var/lib/pod-config-data",
65-
Name: "pod-config-data",
66-
}, {
67-
MountPath: "/var/lib/operator-scripts",
68-
ReadOnly: true,
69-
Name: "operator-scripts",
70-
}, {
71-
MountPath: "/var/lib/kolla/config_files",
72-
ReadOnly: true,
73-
Name: "kolla-config",
74-
}},
56+
VolumeMounts: getGaleraInitVolumeMounts(g),
7557
}},
7658
Containers: []corev1.Container{{
7759
Image: g.Spec.ContainerImage,
@@ -84,16 +66,6 @@ func StatefulSet(g *mariadbv1.Galera) *appsv1.StatefulSet {
8466
}, {
8567
Name: "KOLLA_CONFIG_STRATEGY",
8668
Value: "COPY_ALWAYS",
87-
}, {
88-
Name: "DB_ROOT_PASSWORD",
89-
ValueFrom: &corev1.EnvVarSource{
90-
SecretKeyRef: &corev1.SecretKeySelector{
91-
LocalObjectReference: corev1.LocalObjectReference{
92-
Name: g.Spec.Secret,
93-
},
94-
Key: "DbRootPassword",
95-
},
96-
},
9769
}},
9870
Ports: []corev1.ContainerPort{{
9971
ContainerPort: 3306,
@@ -102,29 +74,7 @@ func StatefulSet(g *mariadbv1.Galera) *appsv1.StatefulSet {
10274
ContainerPort: 4567,
10375
Name: "galera",
10476
}},
105-
VolumeMounts: []corev1.VolumeMount{{
106-
MountPath: "/var/lib/mysql",
107-
Name: "mysql-db",
108-
}, {
109-
MountPath: "/var/lib/config-data",
110-
ReadOnly: true,
111-
Name: "config-data",
112-
}, {
113-
MountPath: "/var/lib/pod-config-data",
114-
Name: "pod-config-data",
115-
}, {
116-
MountPath: "/var/lib/secrets",
117-
ReadOnly: true,
118-
Name: "secrets",
119-
}, {
120-
MountPath: "/var/lib/operator-scripts",
121-
ReadOnly: true,
122-
Name: "operator-scripts",
123-
}, {
124-
MountPath: "/var/lib/kolla/config_files",
125-
ReadOnly: true,
126-
Name: "kolla-config",
127-
}},
77+
VolumeMounts: getGaleraVolumeMounts(g),
12878
StartupProbe: &corev1.Probe{
12979
ProbeHandler: corev1.ProbeHandler{
13080
Exec: &corev1.ExecAction{
@@ -149,92 +99,7 @@ func StatefulSet(g *mariadbv1.Galera) *appsv1.StatefulSet {
14999
},
150100
},
151101
}},
152-
Volumes: []corev1.Volume{
153-
{
154-
Name: "secrets",
155-
VolumeSource: corev1.VolumeSource{
156-
Secret: &corev1.SecretVolumeSource{
157-
SecretName: g.Spec.Secret,
158-
Items: []corev1.KeyToPath{
159-
{
160-
Key: "DbRootPassword",
161-
Path: "dbpassword",
162-
},
163-
},
164-
},
165-
},
166-
},
167-
{
168-
Name: "kolla-config",
169-
VolumeSource: corev1.VolumeSource{
170-
ConfigMap: &corev1.ConfigMapVolumeSource{
171-
LocalObjectReference: corev1.LocalObjectReference{
172-
Name: g.Name + "-config-data",
173-
},
174-
Items: []corev1.KeyToPath{
175-
{
176-
Key: "config.json",
177-
Path: "config.json",
178-
},
179-
},
180-
},
181-
},
182-
},
183-
{
184-
Name: "pod-config-data",
185-
VolumeSource: corev1.VolumeSource{
186-
EmptyDir: &corev1.EmptyDirVolumeSource{},
187-
},
188-
},
189-
{
190-
Name: "config-data",
191-
VolumeSource: corev1.VolumeSource{
192-
ConfigMap: &corev1.ConfigMapVolumeSource{
193-
LocalObjectReference: corev1.LocalObjectReference{
194-
Name: g.Name + "-config-data",
195-
},
196-
Items: []corev1.KeyToPath{
197-
{
198-
Key: "galera.cnf.in",
199-
Path: "galera.cnf.in",
200-
},
201-
{
202-
Key: mariadbv1.CustomServiceConfigFile,
203-
Path: mariadbv1.CustomServiceConfigFile,
204-
},
205-
},
206-
},
207-
},
208-
},
209-
{
210-
Name: "operator-scripts",
211-
VolumeSource: corev1.VolumeSource{
212-
ConfigMap: &corev1.ConfigMapVolumeSource{
213-
LocalObjectReference: corev1.LocalObjectReference{
214-
Name: g.Name + "-scripts",
215-
},
216-
Items: []corev1.KeyToPath{
217-
{
218-
Key: "mysql_bootstrap.sh",
219-
Path: "mysql_bootstrap.sh",
220-
},
221-
{
222-
Key: "mysql_probe.sh",
223-
Path: "mysql_probe.sh",
224-
},
225-
{
226-
Key: "detect_last_commit.sh",
227-
Path: "detect_last_commit.sh",
228-
},
229-
{
230-
Key: "detect_gcomm_and_start.sh",
231-
Path: "detect_gcomm_and_start.sh",
232-
},
233-
},
234-
},
235-
},
236-
},
237-
},
102+
Volumes: getGaleraVolumes(g),
238103
},
239104
},
240105
VolumeClaimTemplates: []corev1.PersistentVolumeClaim{

0 commit comments

Comments
 (0)