From 282b34c0eafef3310eae5968ad4d45f3f58cb97f Mon Sep 17 00:00:00 2001 From: Cybozu Neco Date: Wed, 6 Sep 2023 23:22:57 +0000 Subject: [PATCH] update --- change-pvc-template.html | 71 ++++++++++++++++++++++++++++++++++++++++ print.html | 71 ++++++++++++++++++++++++++++++++++++++++ searchindex.js | 2 +- searchindex.json | 2 +- 4 files changed, 144 insertions(+), 2 deletions(-) diff --git a/change-pvc-template.html b/change-pvc-template.html index e47d3af0e..a49e4497a 100644 --- a/change-pvc-template.html +++ b/change-pvc-template.html @@ -182,6 +182,77 @@

Metrics

If fails to volume size changed, the metrics in moco_cluster_volume_resized_errors_total is incremented after each reconcile, so users can notice anomalies by monitoring this metrics.

See the metrics documentation for more details.

+

Volume reduction

+

MOCO supports PVC reduction, but unlike PVC expansion, the user must perform the operation manually.

+

The steps are as follows:

+
    +
  1. The user modifies the .spec.volumeClaimTemplates of the MySQLCluster and sets a smaller volume size.
  2. +
  3. MOCO updates the .spec.volumeClaimTemplates of the StatefulSet. This does not propagate to existing Pods, PVCs, or PVs.
  4. +
  5. The user manually deletes the MySQL Pod & PVC.
  6. +
  7. Wait for the Pod & PVC to be recreated by the statefulset-controller, and for MOCO to clone the data.
  8. +
  9. Once the cluster becomes Healthy, the user deletes the next Pod and PVC.
  10. +
  11. It is completed when all Pods and PVCs are recreated.
  12. +
+

1. The user modifies the .spec.volumeClaimTemplates of the MySQLCluster and sets a smaller volume size

+

For example, the user modifies the .spec.volumeClaimTemplates of the MySQLCluster as follows:

+
  apiVersion: moco.cybozu.com/v1beta2
+  kind: MySQLCluster
+  metadata:
+    namespace: default
+    name: test
+  spec:
+    replicas: 3
+    podTemplate:
+      spec:
+        containers:
+        - name: mysqld
+          image: quay.io/cybozu/mysql:8.0.30
+    volumeClaimTemplates:
+    - metadata:
+        name: mysql-data
+      spec:
+        accessModes: [ "ReadWriteOnce" ]
+        resources:
+          requests:
+-           storage: 1Gi
++           storage: 500Mi
+
+

2. MOCO updates the .spec.volumeClaimTemplates of the StatefulSet. This does not propagate to existing Pods, PVCs, or PVs

+

The moco-controller will update the .spec.volumeClaimTemplates of the StatefulSet. +The actual modification of the StatefulSet's .spec.volumeClaimTemplates is not allowed, +so this change is achieved by recreating the StatefulSet. +At this time, only the recreation of StatefulSet is performed, without deleting the Pods and PVCs.

+

3. The user manually deletes the MySQL Pod & PVC

+

The user manually deletes the PVC and Pod. +Use the following command to delete them:

+
$ kubectl delete --wait=false pvc <pvc-name>
+$ kubectl delete --grace-period=1 <pod-name>
+
+

4. Wait for the Pod & PVC to be recreated by the statefulset-controller, and for MOCO to clone the data

+

The statefulset-controller recreates Pods and PVCs, creating a new PVC with a reduced size. +Once the MOCO successfully starts a Pod, it begins cloning the data.

+
$ kubectl get mysqlcluster,po,pvc
+NAME                                AVAILABLE   HEALTHY   PRIMARY   SYNCED REPLICAS   ERRANT REPLICAS   LAST BACKUP
+mysqlcluster.moco.cybozu.com/test   True        False     0         2                                   <no value>
+
+NAME              READY   STATUS     RESTARTS   AGE
+pod/moco-test-0   3/3     Running    0          2m14s
+pod/moco-test-1   3/3     Running    0          114s
+pod/moco-test-2   0/3     Init:1/2   0          7s
+
+NAME                                           STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
+persistentvolumeclaim/mysql-data-moco-test-0   Bound    pvc-03c73525-0d6d-49de-b68a-f8af4c4c7faa   1Gi        RWO            standard       2m14s
+persistentvolumeclaim/mysql-data-moco-test-1   Bound    pvc-73c26baa-3432-4c85-b5b6-875ffd2456d9   1Gi        RWO            standard       114s
+persistentvolumeclaim/mysql-data-moco-test-2   Bound    pvc-779b5b3c-3efc-4048-a549-a4bd2d74ed4e   500Mi      RWO            standard       7s
+
+

5. Once the cluster becomes Healthy, the user deletes the next Pod and PVC

+

The user waits until the MySQLCluster state becomes Healthy, and then deletes the next Pod and PVC.

+
$ kubectl get mysqlcluster
+NAME                                AVAILABLE   HEALTHY   PRIMARY   SYNCED REPLICAS   ERRANT REPLICAS   LAST BACKUP
+mysqlcluster.moco.cybozu.com/test   True        True      1         3                                   <no value>
+
+

6. It is completed when all Pods and PVCs are recreated

+

Repeat steps 3 to 5 until all Pods and PVCs are recreated.

References