Stop/Start a MySQL cluster
You can stop/start a cluster to save computing resources. When a cluster is stopped, the computing resources of this cluster are released, which means the pods of Kubernetes are released, but the storage resources are reserved. You can start this cluster again by snapshots if you want to restore the cluster resources.
Stop a cluster
You can stop a cluster by creating an OpsRequest or changing the YAML file of the cluster.
- OpsRequest
- Edit cluster YAML file
kubectl apply -f - <<EOF
apiVersion: apps.kubeblocks.io/v1alpha1
kind: OpsRequest
metadata:
name: ops-stop
namespace: demo
spec:
clusterName: mycluster
type: Stop
EOF
Configure replicas as 0 to delete pods.
apiVersion: apps.kubeblocks.io/v1alpha1
kind: Cluster
metadata:
name: mycluster
spec:
clusterDefinitionRef: apecloud-mysql
clusterVersionRef: ac-mysql-8.0.30
terminationPolicy: Delete
componentSpecs:
- name: mysql
componentDefRef: mysql
disableExporter: true
replicas: 0
volumeClaimTemplates:
- name: data
spec:
storageClassName: standard
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Gi
Start a cluster
You can start a cluster by creating an OpsRequest or changing the YAML file of the cluster.
- OpsRequest
- Edit cluster YAML file
kubectl apply -f - <<EOF
apiVersion: apps.kubeblocks.io/v1alpha1
kind: OpsRequest
metadata:
name: ops-start
namespace: demo
spec:
clusterName: mycluster
type: Start
EOF
Change replicas back to the original amount to start this cluster again.
apiVersion: apps.kubeblocks.io/v1alpha1
kind: Cluster
metadata:
name: mycluster
spec:
clusterDefinitionRef: apecloud-mysql
clusterVersionRef: ac-mysql-8.0.30
terminationPolicy: Delete
componentSpecs:
- name: mysql
componentDefRef: mysql
disableExporter: true
replicas: 3
volumeClaimTemplates:
- name: data
spec:
storageClassName: standard
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Gi