Skip to content

Commit 2951a48

Browse files
committed
Fix mariadb config file permissions and restart pod on config change
Mariadb is using default conf as the conf file is not readable by the mariadb user. Also pass the config hash as an env to the pod to ensure it is recreated when the config changes.
1 parent 2ff4f7b commit 2951a48

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

controllers/mariadb_controller.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,16 @@ func (r *MariaDBReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
295295

296296
op, err = controllerutil.CreateOrPatch(ctx, r.Client, pod, func() error {
297297
pod.Spec.Containers[0].Image = instance.Spec.ContainerImage
298+
pod.Spec.Containers[0].Env = []corev1.EnvVar{
299+
{
300+
Name: "KOLLA_CONFIG_STRATEGY",
301+
Value: "COPY_ALWAYS",
302+
},
303+
{
304+
Name: "CONFIG_HASH",
305+
Value: configHash,
306+
},
307+
}
298308
err := controllerutil.SetControllerReference(instance, pod, r.Scheme)
299309
if err != nil {
300310
return err

templates/mariadb/bin/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{
55
"source": "/var/lib/config-data/galera.cnf",
66
"dest": "/etc/my.cnf.d/galera.cnf",
7-
"owner": "root",
7+
"owner": "mysql",
88
"perm": "0600"
99
}
1010
]

templates/mariadb/bin/galera.cnf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ key_buffer_size = 16M
77

88
[mysqld]
99
basedir = /usr
10-
bind-address = 127.0.0.1
10+
bind-address = *
1111
datadir = /var/lib/mysql
1212
expire_logs_days = 10
1313
innodb_file_per_table = ON

templates/mariadb/bin/init_config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{
55
"source": "/var/lib/config-data/galera.cnf",
66
"dest": "/etc/my.cnf.d/galera.cnf",
7-
"owner": "root",
7+
"owner": "mysql",
88
"perm": "0600"
99
},
1010
{

0 commit comments

Comments
 (0)