github.com/1aal/kubeblocks@v0.0.0-20231107070852-e1c03e598921/docs/user_docs/kubeblocks-for-redis/cluster-management/stop-start-a-redis-cluster.md (about)

     1  ---
     2  title: Stop/Start a Redis cluster
     3  description: How to start/stop a Redis cluster
     4  keywords: [redis, stop a cluster, start a cluster]
     5  sidebar_position: 5
     6  sidebar_label: Stop/Start
     7  ---
     8  
     9  # Stop/Start a Redis Cluster
    10  
    11  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. Start this cluster again if you want to restore the cluster resources from the original storage by snapshots.
    12  
    13  ## Stop a cluster
    14  
    15  ### Option 1. (Recommended) Use kbcli
    16  
    17  Configure the name of your cluster and run the command below to stop this cluster.
    18  
    19  ```bash
    20  kbcli cluster stop <name>
    21  ```
    22  
    23  ***Example***
    24  
    25  ```bash
    26  kbcli cluster stop redis-cluster
    27  ```
    28  
    29  ### Option 2. Create an OpsRequest
    30  
    31  Run the command below to stop a cluster.
    32  ```bash
    33  kubectl apply -f - <<EOF
    34  apiVersion: apps.kubeblocks.io/v1alpha1
    35  kind: OpsRequest
    36  metadata:
    37    generateName: stop-
    38  spec:
    39    # cluster ref
    40    clusterRef: redis-cluster
    41    type: Stop
    42  EOF
    43  ```
    44  
    45  ### Option 3. Change the YAML file of the cluster
    46  
    47  Configure replicas as 0 to delete pods.
    48  
    49  ```yaml
    50  apiVersion: apps.kubeblocks.io/v1alpha1
    51  kind: Cluster
    52  metadata:
    53    name: redis-cluster
    54  spec:
    55    clusterDefinitionRef: redis
    56    clusterVersionRef: redis-7.0.6
    57    terminationPolicy: Delete
    58    componentSpecs:
    59    - name: redis
    60      componentDefRef: redis
    61      monitor: true  
    62      replicas: 0
    63      volumeClaimTemplates:
    64      - name: data
    65        spec:
    66          storageClassName: standard
    67          accessModes:
    68          - ReadWriteOnce
    69          resources:
    70            requests:
    71              storage: 1Gi
    72    - name: redis-sentinel
    73      componentDefRef: redis-sentinel
    74      monitor: true  
    75      replicas: 0
    76      volumeClaimTemplates:
    77      - name: data
    78        spec:
    79          storageClassName: standard
    80          accessModes:
    81          - ReadWriteOnce
    82          resources:
    83            requests:
    84              storage: 1Gi
    85  ```
    86  
    87  ## Start a cluster
    88    
    89  ### Option 1. (Recommended) Use kbcli
    90  
    91  Configure the name of your cluster and run the command below to start this cluster.
    92  
    93  ```bash
    94  kbcli cluster start <name>
    95  ```
    96  
    97  ***Example***
    98  
    99  ```bash
   100  kbcli cluster start redis-cluster
   101  ```
   102  
   103  ### Option 2. Create an OpsRequest
   104  
   105  Run the command below to start a cluster.
   106  
   107  ```yaml
   108  kubectl apply -f - <<EOF
   109  apiVersion: apps.kubeblocks.io/v1alpha1
   110  kind: OpsRequest
   111  metadata:
   112    generateName: start-
   113  spec:
   114    # cluster ref
   115    clusterRef: redis-cluster
   116    type: Start
   117  EOF 
   118  ```
   119  
   120  ### Option 3. Change the YAML file of the cluster
   121  
   122  Change replicas back to the original amount to start this cluster again.
   123  
   124  ```yaml
   125  apiVersion: apps.kubeblocks.io/v1alpha1
   126  kind: Cluster
   127  metadata:
   128      name: redis-cluster
   129  spec:
   130    clusterDefinitionRef: redis
   131    clusterVersionRef: redis-7.0.6
   132    terminationPolicy: Delete
   133    componentSpecs:
   134    - name: redis
   135      componentDefRef: redis
   136      monitor: true  
   137      replicas: 2
   138      volumeClaimTemplates:
   139      - name: data
   140        spec:
   141          storageClassName: standard
   142          accessModes:
   143          - ReadWriteOnce
   144          resources:
   145            requests:
   146              storage: 1Gi
   147    - name: redis-sentinel
   148      componentDefRef: redis-sentinel
   149      monitor: true  
   150      replicas: 3
   151      volumeClaimTemplates:
   152      - name: data
   153        spec:
   154          storageClassName: standard
   155          accessModes:
   156          - ReadWriteOnce
   157          resources:
   158            requests:
   159              storage: 1Gi
   160  ```