Stop/Start a Redis 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 to restore it to the state it was in before it was stopped.
Stop a cluster
-
Configure the name of your cluster and run the command below to stop this cluster.
- OpsRequest
- Edit cluster YAML file
- kbcli
Run the command below to stop a cluster.
kubectl apply -f - <<EOF
apiVersion: apps.kubeblocks.io/v1alpha1
kind: OpsRequest
metadata:
name: ops-stop
namespace: demo
spec:
clusterName: mycluster
type: Stop
EOFkubectl edit cluster mycluster -n demo
Configure the values of
replicas
as 0 to delete pods....
spec:
affinity:
podAntiAffinity: Preferred
topologyKeys:
- kubernetes.io/hostname
clusterDefinitionDef: redis
componentSpecs:
- componentDef: redis-7
enabledLogs:
- running
disableExporter: true
name: redis
replicas: 0 # Change this value
...
- componentDef: redis-sentinel-7
name: redis-sentinel
replicas: 0 # Change this value
...kbcli cluster stop mycluster -n demo
-
Check the status of the cluster to see whether it is stopped.
- kubectl
- kbcli
kubectl get cluster mycluster -n demo
kbcli cluster list -n demo
Start a cluster
-
Configure the name of your cluster and run the command below to start this cluster.
- OpsRequest
- Edit cluster YAML File
- kbcli
Apply an OpsRequest to start the cluster.
kubectl apply -f - <<EOF
apiVersion: apps.kubeblocks.io/v1alpha1
kind: OpsRequest
metadata:
name: ops-start
namespace: demo
spec:
clusterName: mycluster
type: Start
EOFkubectl edit cluster mycluster -n demo
Change the values of
replicas
back to the original amount to start this cluster again....
spec:
affinity:
podAntiAffinity: Preferred
topologyKeys:
- kubernetes.io/hostname
clusterDefinitionDef: redis
componentSpecs:
- componentDef: redis-7
enabledLogs:
- running
disableExporter: true
name: redis
replicas: 3 # Change this value
...
- componentDef: redis-sentinel-7
name: redis-sentinel
replicas: 3 # Change this value
...kbcli cluster start mycluster -n demo
-
Check the status of the cluster to see whether it is running again.
- kubectl
- kbcli
kubectl get cluster mycluster -n demo
kbcli cluster list -n demo