---
# System prepended metadata

title: 多集群场景下有状态应用扩缩容过程中的副本变更顺序

---

# 多集群场景下有状态应用扩缩容过程中的副本变更顺序

# 扩容场景

例：

当前分布：

```text
cluster-01：3
cluster-02：2
```

预期分布：

```text
cluster-02：3
cluster-03：1
cluster-04：3
```

操作集合：

```text
Add pod-0.cluster-03 in cluster-03
Current distribution:
  cluster-01: 3 replicas
  cluster-02: 2 replicas
  cluster-03: 1 replicas
----------
Add pod-0.cluster-04 in cluster-04
Current distribution:
  cluster-01: 3 replicas
  cluster-02: 2 replicas
  cluster-03: 1 replicas
  cluster-04: 1 replicas
----------
Remove pod-0.cluster-01 in cluster-01
Current distribution:
  cluster-01: 2 replicas
  cluster-02: 2 replicas
  cluster-03: 1 replicas
  cluster-04: 1 replicas
----------
Add pod-1.cluster-04 in cluster-04
Current distribution:
  cluster-01: 2 replicas
  cluster-02: 2 replicas
  cluster-03: 1 replicas
  cluster-04: 2 replicas
----------
Remove pod-1.cluster-01 in cluster-01
Current distribution:
  cluster-01: 1 replicas
  cluster-02: 2 replicas
  cluster-03: 1 replicas
  cluster-04: 2 replicas
----------
Add pod-2.cluster-02 in cluster-02
Current distribution:
  cluster-01: 1 replicas
  cluster-02: 3 replicas
  cluster-03: 1 replicas
  cluster-04: 2 replicas
----------
Add pod-2.cluster-04 in cluster-04
Current distribution:
  cluster-01: 1 replicas
  cluster-02: 3 replicas
  cluster-03: 1 replicas
  cluster-04: 3 replicas
----------
Remove pod-2.cluster-01 in cluster-01
Current distribution:
  cluster-01: 0 replicas
  cluster-02: 3 replicas
  cluster-03: 1 replicas
  cluster-04: 3 replicas
----------

```

# 缩容场景

当前分布：

```text
cluster-02：3
cluster-03：1
cluster-04：3
```

预期分布：

```text
cluster-01：3
cluster-02：2
```

操作集合：

```text
Add pod-0.cluster-01 in cluster-01
Current distribution:
  cluster-01: 1 replicas
  cluster-02: 3 replicas
  cluster-03: 1 replicas
  cluster-04: 3 replicas
----------
Remove pod-0.cluster-03 in cluster-03
Current distribution:
  cluster-01: 1 replicas
  cluster-02: 3 replicas
  cluster-03: 0 replicas
  cluster-04: 3 replicas
----------
Remove pod-0.cluster-04 in cluster-04
Current distribution:
  cluster-01: 1 replicas
  cluster-02: 3 replicas
  cluster-03: 0 replicas
  cluster-04: 2 replicas
----------
Add pod-1.cluster-01 in cluster-01
Current distribution:
  cluster-01: 2 replicas
  cluster-02: 3 replicas
  cluster-03: 0 replicas
  cluster-04: 2 replicas
----------
Remove pod-1.cluster-04 in cluster-04
Current distribution:
  cluster-01: 2 replicas
  cluster-02: 3 replicas
  cluster-03: 0 replicas
  cluster-04: 1 replicas
----------
Add pod-2.cluster-01 in cluster-01
Current distribution:
  cluster-01: 3 replicas
  cluster-02: 3 replicas
  cluster-03: 0 replicas
  cluster-04: 1 replicas
----------
Remove pod-2.cluster-02 in cluster-02
Current distribution:
  cluster-01: 3 replicas
  cluster-02: 2 replicas
  cluster-03: 0 replicas
  cluster-04: 1 replicas
----------
Remove pod-2.cluster-04 in cluster-04
Current distribution:
  cluster-01: 3 replicas
  cluster-02: 2 replicas
  cluster-03: 0 replicas
  cluster-04: 0 replicas
----------

```