taint 跟 node affinity 雖然都是屬於 scheduling 的一部份,但要達成的目的其實完全相反:
共有三種,分別是 NoSchedule, PreferNoSchedule & NoExecute
Key
Value
Effect
而設定 node taint 很簡單,透過 kubectl 執行以下指令將 3 個屬性給入即可即可:
kubectl taint nodes node1 key=value:NoSchedule
以下是一個實際操作範例:
$ kubectl get node
NAME STATUS ROLES AGE VERSION
... (略)
leon-k8s-node03 Ready node 15d v1.12.1
leon-k8s-node04 Ready node 15d v1.12.1
leon-k8s-node05 Ready node 15d v1.12.1
# 檢視 node 狀態細節,查看 taint 設定狀態
# 可以看出目前並沒有任何的 taint 設定
$ kubectl describe node/leon-k8s-node03
Name: leon-k8s-node03
Roles: node
Labels: beta.kubernetes.io/arch=amd64
beta.kubernetes.io/os=linux
kubernetes.io/hostname=leon-k8s-node03
node-role.kubernetes.io/node=true
... (略)
Taints: <none>
Unschedulable: false
... (略)
# 為 node03 加上 taint
$ kubectl taint nodes leon-k8s-node03 key=value:NoSchedule
node/leon-k8s-node03 tainted
# 重新檢視 node 狀態細節,察看 taint 設定狀態
# 目前已經多了一個 taint 的設定
$ kubectl describe node/leon-k8s-node03
Name: leon-k8s-node03
Roles: node
Labels: beta.kubernetes.io/arch=amd64
beta.kubernetes.io/os=linux
kubernetes.io/hostname=leon-k8s-node03
node-role.kubernetes.io/node=true
... (略)
Taints: key=value:NoSchedule
Unschedulable: false
... (略)
當以上步驟完成後,後續新增進來的 pod 就不會被分派到這個 node 上。
kubectl taint nodes node1 key:NoSchedule-
# 表示可以接受"帶有 key=value & effect=NoSchedule" 的 taint
tolerations:
- key: "key"
operator: "Equal"
value: "value"
effect: "NoSchedule"
也可以是下面這樣設定:
# 表示可以接受"存在 key(不論 value 為何) & effect=NoSchedule" 的 taint
tolerations:
- key: "key"
operator: "Exists"
effect: "NoSchedule"
...
spec:
containers:
- image: xxx/xxx
imagePullPolicy: Always
name: application-job
ports:
...
dnsPolicy: ClusterFirst
nodeSelector:
alpha.eksctl.io/nodegroup-name: Worker-Nodes-PRODUCTION-MW-SP
tolerations:
- effect: NoSchedule
key: dedicated
operator: Equal
value: application-job
使用 label taint node groups
$ kubectl taint node -l alpha.eksctl.io/nodegroup-name=redis-nodegroup redis=true:NoSchedule
...
node/ip-172-20-101-31.ap-northeast-1.compute.internal tainted
node/ip-172-20-129-158.ap-northeast-1.compute.internal tainted
REF: https://aws.amazon.com/vpc/pricing/#natgatewaypricing https://aws.amazon.com/privatelink/pricing/ https://docs.aws.amazon.com/AmazonECR/latest/userguide/vpc-endpoints.html
Aug 22, 2021學習力 在沒有工作task 時,懂的利用時間去充實自己未具備的技能,並在遇到可以使用此技能的在工作上提出,並實用。 敏捷力 在工作被派與任務時,能夠快速且準確的把任務完成。 對話力 在工作發現問題時,懂的與團隊溝通並提出想法,以解決問題。 促進團隊成功
Aug 10, 2021[OSEv3:children] masters etcd nodes [masters] pmst01.com.tw pmst02.com.tw pmst03.com.tw
Apr 11, 2021Type the following into the file. These statements produce a Dockerfile that describes the following: The base stage includes environment setup which we expect to change very rarely, if at all. Creates a new Docker image from the base image node:alpine. This base image has node.js on it and is optimized for small size. Add curl to the base image to support Docker health checks. Creates a directory on the image where the application files can be copied.
Dec 11, 2020or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up