cybozu-go / moco

MySQL operator on Kubernetes using GTID-based semi-synchronous replication.
https://cybozu-go.github.io/moco/
Apache License 2.0
278 stars 22 forks source link

Scaling cluster down to 0 #659

Closed vsliouniaev closed 4 months ago

vsliouniaev commented 7 months ago

What

I'm hoping to use the operator to provide test clusters for developers. Since the development cycle is not 24 hours it would be more cost-effective to shut down the instances when not in use to free up resources.

I can see that deleting the entire cluster wipes the root access credentials as well as all PVCs, which is not ideal for this setup.

How

It would be convenient if the option to scale to 0 replicas was allowed by the operator.

Alternatively a different option to suspend the cluster that's not tied to the replica count may be preferable if some other logic is tied to increasing the number of replicas.

Checklist

ymmt2005 commented 7 months ago

My gut feeling is like the following.

Add a mode of operation to the moco-controller so that it removes StatefulSet but keeps the PVCs and all other resources. When the user wants to restore the cluster, the moco-controller will just create the StatefulSet, which will reuse the PVCs.

Does it sound good?

vsliouniaev commented 7 months ago

Sounds like that would work. Scaling the STS down to 0 would probably be equivalent.

vsliouniaev commented 6 months ago

I've done a little local experimenting with and have it working reasonably well, but the controllers are throwing a lot of benign errors as a result. If this approach proves workable in my setup I'll clean up the implementation. My approach is to add another property to the spec, rather than setting the spec.replicas=0, since the replica count in the CRD has implications for clustering.