K8S调度器 污点使用方法

作者: lyy910203 | 来源:发表于2019-06-13 15:31 被阅读2次
    默认调度是:最大空闲资源调度

    调度器

    预算策略

    CheckNodeCondition:检查节点网络磁盘等是否正常

    GeneralPredicates:通用预选策略

    HostName:检查pod对象是否定义了pod.spec.hostname

    podFitsHostPorts: pods.spec.containers.ports.hostPort

    MatchNNodeSelector:pods.spec.nodeSelector

    PodFitsResources:检查Pod资源需求能否被节点满足

    NoDiskConflict:检查pod依赖的存储卷能否满足,默认不启用

    PodToleratesNodeTaints:检查Pod上的spec.tolerations客容忍五点是否包含节点污点

    PodToleratesNodeBoExecteTaints:默认不启用

    CheckNodeLabelPresence:检查节点标签存在,默认不启用

    CheckServiceAffinity:根据当前pod所属pod所属对象services放在同一个node

    污点调度

    • 查看节点污点

    kubectl describe node node-name
    

    官方文档:https://kubernetes.io/zh/docs/concepts/configuration/taint-and-toleration/

    • 节点添加污点

    kubectl taint nodes node1 key=value:NoSchedule
    
    kubectl taint nodes node1 key=value:NoExecute
    
    kubectl taint nodes node1 key=value:PreferNoSchedule
    
      • NoSchedule:K8Snode添加这个effecf类型污点,新的不能容忍的pod不能再调度过来,但是老的运行在node上不受影响
      • NoExecute:K8Snode添加这个effecf类型污点,新的不能容忍的pod不能调度过来,老的pod也会被驱逐
      • PreferNoSchedule:pod会尝试将pod分配到该节点
    • 节点删除污点:

    kubectl taint nodes kube11 key:NoSchedule-
    
    • pod设置容忍一个污点

    apiVersion: apps/v1Beta1
    kind: Deployment
    metadata:
      name: nginx-deploy
    spec:
      replicas: 1
        selector:
          matchLabels:
            app: nginx
      template:
        metadata:
          labels:
            app: nginx
        spec:
          containers:
          - name: nginx
            images: nginx:laste
            ports:
            - containerPort: 80       
        tolerations:  #containers同级
        - key: "key1"          #能容忍的污点key
          operator: "Equal"    #Equal等于表示key=value , Exists不等于,表示当值不等于下面value正常
          value: "value1"      #值
          effect: "NoExecute"  #effect策略,见上面
          tolerationSeconds: 3600  #原始的pod多久驱逐,注意只有effect: "NoExecute"才能设置,不然报错
    
    

    相关文章

      网友评论

        本文标题:K8S调度器 污点使用方法

        本文链接:https://www.haomeiwen.com/subject/iyssfctx.html