Changing StatefulSet PVCs¶
Limitation of changing StatefulSet PVCs comes from K8s, therefore some manual steps are required for changing StorageClass/Size of the PVC. Also, this works without disruption and data loss only if you have 3 and more replicas.
Change StorageClass or shrink PVC¶
In some cases you want to migrate a MariaDB or RabbitMQ to another PVC. For example if you have to change the StorageClass. In this case, follow these steps and always think of backup:
In case of a PVC shrink, ensure that the PVC will still be large enough
Update StorageClass/PVC Size in Yaook OpenStack CR (for example GlanceDeployment) to the new StorageClass/PVC Size
You will get error from
infra-operator(updates for StatefulSet PVCs are forbidden in K8s)
Scale down
infra-operatoror pause owner of the StatefulSet (e.g. MySQLService)Delete the StatefulSet but not the pods. This can be done with this command:
kubectl get sts -o yaml <StatefulSetName> > <StatefulSetName>-backup.yaml kubectl delete sts --cascade=orphan <StatefulSetName>
Check if the pods are still there. IF NOT, DO NOT CONTINUE (in such case undo the previous steps to re-create the pods)
Mark all PVCs for deletion - NO FORCE
For more certainty that data will not be lost but also more manual steps, mark only PVC from n-1 replica for deletion
Start
infra-operatoror unpause owner of the StatefulSet (e.g. MySQLService)Wait until the
infra-operatorrecreates the StatefulSetTrigger restart of the the StatefulSet if it does not restart by itself
If you decided in step 6, to mark only n-1 replica, do not trigger restart. Manually delete (no force) n-1 replica and wait until it will join cluster and is ready. Then you can repeat with n-2, …, 0 replica (mark pvc for deletion and delete corresponding replica)
Wait until restart has completed
Success
Extend PVC size¶
For increasing the volume size (this works at least for StorageClasses supporting volume expansion), follow these steps:
Increase size in Yaook OpenStack CR (for example GlanceDeployment)
You will get error from
infra-operator(updates for StatefulSet PVCs are forbidden in K8s)
Update the PVC size for all the replicas of the STS in the K8s manually
Delete the StatefulSet but not the pods. This can be done with this command:
kubectl get sts -o yaml <StatefulSetName> > <StatefulSetName>-backup.yaml kubectl delete sts --cascade=orphan <StatefulSetName>
Wait until the
infra-operatorrecreates the StatefulSetTrigger restart of the the StatefulSet if needed
Success