Skip to content

Commit a07cecd

Browse files
authored
Improve MySQL and MariaDB reconfiguration guides (#1090)
Signed-off-by: Rabbani Islam Refat <refat@appscode.com>
1 parent 28078dd commit a07cecd

13 files changed

Lines changed: 99 additions & 4 deletions

‎docs/guides/mariadb/reconfigure/cluster/examples/mdops-reconfigure-apply-config.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ spec:
88
databaseRef:
99
name: sample-mariadb
1010
configuration:
11+
restart: auto
1112
applyConfig:
1213
new-md-config.cnf: |
1314
[mysqld]

‎docs/guides/mariadb/reconfigure/cluster/examples/reconfigure-remove.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ spec:
88
databaseRef:
99
name: sample-mariadb
1010
configuration:
11+
restart: auto
1112
removeCustomConfig: true

‎docs/guides/mariadb/reconfigure/cluster/examples/reconfigure-using-secret.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ spec:
88
databaseRef:
99
name: sample-mariadb
1010
configuration:
11+
restart: auto
1112
configSecret:
1213
name: new-md-configuration

‎docs/guides/mariadb/reconfigure/cluster/index.md‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ spec:
184184
databaseRef:
185185
name: sample-mariadb
186186
configuration:
187+
restart: auto
187188
configSecret:
188189
name: new-md-configuration
189190
```
@@ -193,6 +194,10 @@ Here,
193194
- `spec.databaseRef.name` specifies that we are reconfiguring `sample-mariadb` database.
194195
- `spec.type` specifies that we are performing `Reconfigure` on our database.
195196
- `spec.configuration.configSecret.name` specifies the name of the new secret.
197+
- `spec.configuration.restart` controls restart behavior
198+
- With `auto` (the default) the operator decides whether a restart is needed based on the provided configuration.
199+
- Use `"false"` for changes that can be applied dynamically without a restart.
200+
- Use `"true"` for changes that require a restart to take effect.
196201

197202
Let's create the `MariaDBOpsRequest` CR we have shown above,
198203

@@ -304,7 +309,7 @@ Bye
304309
As we can see from the configuration has changed, the value of `max_connections` has been changed from `200` to `250` and and the `read_buffer_size` has been changed `1048576` to `122880`. So the reconfiguration of the database is successful.
305310

306311

307-
### Reconfigure Existing Config Secret
312+
### Reconfigure Using Apply Config
308313

309314
Now, we will create a new `MariaDBOpsRequest` to reconfigure our existing secret `new-md-configuration` by modifying our `new-md-config.cnf` file using `applyConfig`. The `MariaDBOpsRequest` yaml is given below,
310315

@@ -319,6 +324,7 @@ spec:
319324
databaseRef:
320325
name: sample-mariadb
321326
configuration:
327+
restart: auto
322328
applyConfig:
323329
new-md-config.cnf: |
324330
[mysqld]
@@ -511,9 +517,12 @@ spec:
511517
databaseRef:
512518
name: sample-mariadb
513519
configuration:
520+
restart: auto
514521
removeCustomConfig: true
515522
```
516523
524+
> **Note:** Removing custom configuration requires a restart; use `restart: auto` or `restart: "true"`, as `restart: "false"` causes the OpsRequest to fail.
525+
517526
Here,
518527

519528
- `spec.databaseRef.name` specifies that we are reconfiguring `mdops-reconfigure-remove` database.

‎docs/guides/mariadb/reconfigure/overview/index.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ The Reconfiguring MariaDB process consists of the following steps:
4747

4848
7. Then the `KubeDB` Enterprise operator will replace the existing configuration with the new configuration provided or merge the new configuration with the existing configuration according to the `MariaDBOpsRequest` CR.
4949

50-
8. Then the `KubeDB` Enterprise operator will restart the related PetSet Pods so that they restart with the new configuration defined in the `MariaDBOpsRequest` CR.
50+
8. Then the `KubeDB` Enterprise operator applies the configuration defined in the `MariaDBOpsRequest` CR, restarting the related PetSet Pods when needed according to `spec.configuration.restart`.
5151

5252
9. After the successful reconfiguring of the `MariaDB`, the `KubeDB` Enterprise operator resumes the `MariaDB` object so that the `KubeDB` Community operator resumes its usual operations.
5353

‎docs/guides/mariadb/reconfigure/standalone/examples/mdops-reconfigure-apply-config.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ spec:
88
databaseRef:
99
name: sample-mariadb
1010
configuration:
11+
restart: auto
1112
applyConfig:
1213
new-md-config.cnf: |
1314
[mysqld]

‎docs/guides/mariadb/reconfigure/standalone/examples/reconfigure-remove.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ spec:
88
databaseRef:
99
name: sample-mariadb
1010
configuration:
11+
restart: auto
1112
removeCustomConfig: true

‎docs/guides/mariadb/reconfigure/standalone/examples/reconfigure-using-secret.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ spec:
88
databaseRef:
99
name: sample-mariadb
1010
configuration:
11+
restart: auto
1112
configSecret:
1213
name: new-md-configuration

‎docs/guides/mariadb/reconfigure/standalone/index.md‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ spec:
180180
databaseRef:
181181
name: sample-mariadb
182182
configuration:
183+
restart: auto
183184
configSecret:
184185
name: new-md-configuration
185186
```
@@ -189,6 +190,10 @@ Here,
189190
- `spec.databaseRef.name` specifies that we are reconfiguring `mdops-reconfigure-config` database.
190191
- `spec.type` specifies that we are performing `Reconfigure` on our database.
191192
- `spec.configuration.configSecret.name` specifies the name of the new secret.
193+
- `spec.configuration.restart` controls restart behavior
194+
- With `auto` (the default) the operator decides whether a restart is needed based on the provided configuration.
195+
- Use `"false"` for changes that can be applied dynamically without a restart.
196+
- Use `"true"` for changes that require a restart to take effect.
192197

193198
Let's create the `MariaDBOpsRequest` CR we have shown above,
194199

@@ -297,7 +302,7 @@ Bye
297302
As we can see from the configuration has changed, the value of `max_connections` has been changed from `200` to `250` and and the `read_buffer_size` has been changed `1048576` to `122880`. So the reconfiguration of the database is successful.
298303

299304

300-
### Reconfigure Existing Config Secret
305+
### Reconfigure Using Apply Config
301306

302307
Now, we will create a new `MariaDBOpsRequest` to reconfigure our existing secret `new-md-configuration` by modifying our `new-md-config.cnf` file using `applyConfig`. The `MariaDBOpsRequest` yaml is given below,
303308

@@ -312,6 +317,7 @@ spec:
312317
databaseRef:
313318
name: sample-mariadb
314319
configuration:
320+
restart: auto
315321
applyConfig:
316322
new-md-config.cnf: |
317323
[mysqld]
@@ -502,9 +508,12 @@ spec:
502508
databaseRef:
503509
name: sample-mariadb
504510
configuration:
511+
restart: auto
505512
removeCustomConfig: true
506513
```
507514

515+
> **Note:** Removing custom configuration requires a restart; use `restart: auto` or `restart: "true"`, as `restart: "false"` causes the OpsRequest to fail.
516+
508517
Here,
509518

510519
- `spec.databaseRef.name` specifies that we are reconfiguring `mdops-reconfigure-remove` database.

‎docs/guides/mysql/reconfigure/reconfigure-steps/index.md‎

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ spec:
324324
databaseRef:
325325
name: sample-mysql
326326
configuration:
327+
restart: auto
327328
configSecret:
328329
name: new-my-configuration
329330
```
@@ -333,6 +334,11 @@ Here,
333334
- `spec.databaseRef.name` specifies that we are reconfiguring `sample-mysql` database.
334335
- `spec.type` specifies that we are performing `Reconfigure` on our database.
335336
- `spec.configuration.configSecret.name` specifies the name of the new secret.
337+
- `spec.configuration.restart` controls restart behavior
338+
- With `auto` (the default) the operator decides whether a restart is needed based on the provided configuration.
339+
- Use `"false"` for changes that can be applied dynamically without a restart.
340+
- Use `"true"` for changes that require a restart to take effect.
341+
336342

337343
Let's create the `MySQLOpsRequest` CR we have shown above,
338344

@@ -491,6 +497,50 @@ mysql>
491497

492498
As we can see from the configuration has changed, the value of `max_connections` has been changed from `200` to `250` and and the `read_buffer_size` has been changed `1048576` to `122880`. So the reconfiguration of the database is successful.
493499

500+
### Reconfigure Using Apply Config
501+
502+
Use `spec.configuration.applyConfig` to update configuration files without creating a new config secret. The following request changes the two settings in `new-my-config.cnf`:
503+
504+
```yaml
505+
apiVersion: ops.kubedb.com/v1alpha1
506+
kind: MySQLOpsRequest
507+
metadata:
508+
name: myops-reconfigure-apply-config
509+
namespace: demo
510+
spec:
511+
type: Reconfigure
512+
databaseRef:
513+
name: sample-mysql
514+
configuration:
515+
restart: auto
516+
applyConfig:
517+
new-my-config.cnf: |
518+
[mysqld]
519+
max_connections = 230
520+
read_buffer_size = 1064960
521+
```
522+
523+
`applyConfig` can modify multiple settings and can also be used when no config secret exists. Apply the request:
524+
525+
```bash
526+
$ kubectl apply -f https://github.com/kubedb/docs/raw/{{< param "info.version" >}}/docs/guides/mysql/reconfigure/reconfigure-steps/yamls/reconfigure-apply-config.yaml
527+
$ kubectl get mysqlopsrequest -n demo myops-reconfigure-apply-config -w
528+
```
529+
530+
Once the request is `Successful`, connect to MySQL and verify the updated values:
531+
532+
```bash
533+
$ kubectl exec -it -n demo sample-mysql-0 -- bash
534+
bash-4.4# mysql -u${MYSQL_ROOT_USERNAME} -p${MYSQL_ROOT_PASSWORD}
535+
```
536+
537+
```sql
538+
mysql> SHOW VARIABLES LIKE 'max_connections';
539+
-- Expected value: 230
540+
mysql> SHOW VARIABLES LIKE 'read_buffer_size';
541+
-- Expected value: 1064960
542+
```
543+
494544
### Remove Custom Configuration
495545

496546
We can also remove exisiting custom config using `MySQLOpsRequest`. Provide `true` to field `spec.configuration.removeCustomConfig` and make an Ops Request to remove existing custom configuration.
@@ -510,9 +560,12 @@ spec:
510560
databaseRef:
511561
name: sample-mysql
512562
configuration:
563+
restart: auto
513564
removeCustomConfig: true
514565
```
515566

567+
> **Note:** Removing custom configuration requires a restart; use `restart: auto` or `restart: "true"`, as `restart: "false"` causes the OpsRequest to fail.
568+
516569
Here,
517570

518571
- `spec.databaseRef.name` specifies that we are reconfiguring `myops-reconfigure-remove` database.
@@ -586,6 +639,6 @@ To clean up the Kubernetes resources created by this tutorial, run:
586639

587640
```bash
588641
$ kubectl delete mysql -n demo sample-mysql
589-
$ kubectl delete mysqlopsrequest -n demo myops-reconfigure-config myops-reconfigure-remove
642+
$ kubectl delete mysqlopsrequest -n demo myops-reconfigure-config myops-reconfigure-apply-config myops-reconfigure-remove
590643
$ kubectl delete ns demo
591644
```

0 commit comments

Comments
 (0)