
# 配置弹性实例的高可用调度
#### 应用场景
在使用 CCE 弹性到 CCI（Bursting）功能时，为了保证弹性出的 Pod 不会因为单点故障而失效，同样需要配置多 AZ 调度策略。这能确保当您应对业务洪峰时，弹性资源具备高可靠性。
#### 弹性实例多 AZ 高可用（TopologySpreadConstraints）
对于 Bursting 场景（基于标准 K8s），推荐使用 **Pod 拓扑分布约束（Topology Spread Constraints）**。相比传统的反亲和性，它能更精细地控制 Pod 在不同 AZ 间的分布偏差。
**Key**: topology.kubernetes.io/zone
```
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    bursting.cci.io/burst-to-cci: enforce          
  name: app-bursting-ha
spec:
  replicas: 5
  selector:
    matchLabels:
      app: bursting-app
  template:
    metadata:
      labels:
        app: bursting-app
    spec:
      # 确保 Pod 在不同 AZ 间均匀分布，最大偏差为 1
      topologySpreadConstraints:
        - maxSkew: 1
          topologyKey: topology.kubernetes.io/zone
          whenUnsatisfiable: ScheduleAnyway # 资源不足时允许打破约束，优先保障业务运行
          labelSelector:
            matchLabels:
              app: bursting-app
      containers:
      - name: container-0
        image: nginx:alpine
```
#### 弹性实例指定 AZ 调度
若您希望弹性出的 Pod 仅运行在特定的可用区（例如为了通过内网低时延访问该 AZ 下的 CCE 节点数据库），可以直接使用 nodeSelector 或 nodeAffinity。
使用 NodeSelector（最简方式）：
YAML示例：
```
apiVersion: v1
kind: Pod
metadata:
  labels:
    bursting.cci.io/burst-to-cci: enforce 
  name: bursting-pinned-pod
spec:
  nodeSelector:
    # 强制调度到指定 AZ
    topology.kubernetes.io/zone: cn-north-4a
  containers:
  - name: nginx
    image: nginx:latest
```
