51工具盒子

依楼听风雨
笑看云卷云舒,淡观潮起潮落

k8s Pod调度之节点选择器nodeSelector

k8s Pod调度之节点选择器nodeSelector

1.给节点打标签

kubectl label nodes master231 type=ssd

kubectl label nodes worker233 type=ssd

kubectl label nodes worker232 type=hdd

kubectl get nodes --show-labels

2.配置资源清单

cat 01-nodeSelector.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: deploy-tolerations-nodeselector
spec:
  replicas: 10
  selector:
    matchExpressions:
    - key: apps
      values: 
      - "v1"
      - "v2"
      operator: NotIn
  template:
    metadata:
      labels:
        school: baimei
    spec:
      # 基于节点的标签进行调度,将Pod调度到包含key为type,value为ssd的节点上。
      nodeSelector:
        type: ssd
      # 配置污点容忍
      tolerations:
      - key: school
        operator: Exists
      - key: class
        effect: NoSchedule
      - key: node-role.kubernetes.io/master
        effect: NoSchedule
      containers:
      - name: v1
        image: harbor.baimei.com/baimei-apps/apps:v1
赞(7)
未经允许不得转载:工具盒子 » k8s Pod调度之节点选择器nodeSelector