思路
- 集群选择3个控制节点的高可用模式。
- 创建节点选择在不同的可用区,在多个可用区(AZ)多个节点的情况下,根据自身业务需求合理的配置自定义调度策略,可达到资源分配的最大化。
- 工作负载创建时设置实例数需大于2个。
- 设置工作负载亲和性规则,尽量让Pod分布在不同可用区、不同节点上。
反亲和配置
kind: Deployment
apiVersion: apps/v1
metadata:
name: nginx
namespace: default
spec:
replicas: 2
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: container-0
image: nginx:alpine
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 50
podAffinityTerm:
labelSelector:
matchExpressions:
- key: app
operator: In
values:
- nginx
namespaces:
- default
topologyKey: failure-domain.beta.kubernetes.io/zone
- weight: 50
podAffinityTerm:
labelSelector:
matchExpressions:
- key: app
operator: In
values:
- nginx
namespaces:
- default
topologyKey: kubernetes.io/hostname
imagePullSecrets:
- name: default-secret