文章來源:Pod rebalancing and allocations
簡單整理如下:
- 應用程式是 deployment,有兩個 pod
- 本來只有一個 node,兩個 pod 都會佈署在上面,所以如果一個 node 掛了,那麼應用程式就無法回應了。現在增加另外一個 node ,一般會預期 pod 移動一個到新的 node 上,但實際上 Kubernetes 不會做任何動作。
可以怎麼做?
- 用 Pod (anti-)affinity (參考:https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/)
- 用 Pod topology spread constraints
- 用 descheduler
Pod affinity
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
namespace: ellery-lab
spec:
# 省略
template:
metadata:
labels:
app: MyTestApp
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: disktype
operator: In
values:
- ssd
pod topology spread constraints
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
namespace: ellery-lab
spec:
# 省略
template:
metadata:
labels:
app: MyTestApp
spec:
topologySpreadConstraints:
- maxSkew: 1
topologyKey: zone
whenUnsatisfiable: DoNotSchedule
labelSelector:
matchLabels:
foo: bar
descheduler
這個是需要另外安裝的,安裝以後會在 kube-system 裏面找到,是一個 pod 。
The descheduler pod is run as a critical pod in the kube-system namespace to avoid being evicted by itself or by the kubelet
安裝完成以後,還需要設定 policy ,比較麻煩一些,但可以做到動態的處理,功能也比較多。
沒有留言:
張貼留言