cybozu-go / moco

MySQL operator on Kubernetes using GTID-based semi-synchronous replication.

Home Page:https://cybozu-go.github.io/moco/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Scaling cluster down to 0

vsliouniaev opened this issue · comments

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

  • Finish implementation of the issue
  • Test all functions
  • Have enough logs to trace activities
  • Notify developers of necessary actions

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?

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

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.