您的位置 首页 k8s

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

 

欢迎来撩 : 汇总all

白眉大叔

关于白眉大叔linux云计算: 白眉大叔

热门文章