我在一个集群中有 5 个节点(测试)。我已将它们标记为以下内容:
节点:
- 命名空间=A
- 命名空间=A
- 命名空间=B
- 命名空间=B
- 命名空间=C
我应用了污点和容忍度,nodeAffinity 和 podAntiAffinity。我们的节点启用了自动缩放。但是,我们的节点并没有扩大,所有的 pod 都在 1 个节点中。我在这个链接Kubernetes 中读过:在集群中均匀分布副本,使用 podAntiAffinity、节点 Affinity、污点和容忍度并不能保证这个要求。我们的要求是,1 个 pod 应该均匀地部署在节点上,并且应该相应地扩展。
我错过了什么?
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: prometheus
labels:
app: prometheus
spec:
serviceName: "prometheus"
selector:
matchLabels:
name: prometheus
template:
metadata:
labels:
name: prometheus
app: prometheus
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: namespace
operator: In
values:
- A
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- podAffinityTerm:
labelSelector:
matchExpressions:
- key: app
operator: In
values:
- prometheus
topologyKey: kubernetes.io/hostname
weight: 100
containers:
- name: prometheus
image: quay.io/prometheus/prometheus:v2.6.0
resources:
limits:
memory: 200Mi
requests:
cpu: 100m
memory: 200Mi
terminationGracePeriodSeconds: 30
tolerations:
- key: namespace
operator: Equal
value: A