• Kubernetes 调度器


    先建立一个pod4

    kubectl apply -f pod4.yaml

    这个pod有node亲和性,指定到了cluster-3

    apiVersion: v1
    kind: Pod
    metadata:
      name: myapp-pod4
      labels:
        app: myapp-pod4
        version: v1
    spec:
      containers: 
      -  name: myapp-pod4
         image: nginx
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: kubernetes.io/hostname
                operator: In
                values:
                - xgcloud-ops-k8s-cluster-3.novalocal
          preferredDuringSchedulingIgnoredDuringExecution:
          - weight: 1
            preference:
              matchExpressions:
              - key: kubernetes.io/hostname
                operator: In
                values:
                - xgcloud-ops-k8s-cluster-5.novalocal

    kubectl get pod -o wide

    给node打污点:

    # 设置污点 
    kubectl taint nodes node1 key1=value1:NoSchedule 
    # 节点说明中,查找 Taints 字段 
    kubectl describe pod pod-name 
    # 去除污点 
    kubectl taint nodes node1 key1:NoSchedule-

    加污点:

    kubectl taint nodes xgcloud-ops-k8s-cluster-3.novalocal check=wtl:NoExecute

    删除污点:

    kubectl taint node xgcloud-ops-k8s-cluster-3.novalocal check=wtl:NoExecute-  

    查看污点:

    kubectl describe node/xgcloud-ops-k8s-cluster-3.novalocal

     

     

     因为不是deployment,所以pod被驱逐之后没有在建立,就没了

    容忍(tolerations)

    如果 operator 的值是 Exists,则 value 属性可省略

    如果 operator 的值是 Equal,则表示其 key 与 value 之间的关系是 equal(等于)

    如果不指定 operator 属性,则默认值为 Equal

    另外,还有两个特殊值: 空的 key 如果再配合 Exists 就能匹配所有的 key 与 value,也就是是能容忍所有节点的所有 Taints 空的 effect 匹配所有的 effect

    给pod4设置容忍

    apiVersion: v1
    kind: Pod
    metadata:
      name: myapp-pod4
      labels:
        app: myapp-pod4
        version: v1
    spec:
      containers: 
      -  name: myapp-pod4
         image: nginx
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: kubernetes.io/hostname
                operator: In
                values:
                - xgcloud-ops-k8s-cluster-3.novalocal
          preferredDuringSchedulingIgnoredDuringExecution:
          - weight: 1
            preference:
              matchExpressions:
              - key: kubernetes.io/hostname
                operator: In
                values:
                - xgcloud-ops-k8s-cluster-5.novalocal
      tolerations:
      - key: "check"
        operator: "Equal"
        value: "wtl"
        effect: "NoExecute"
        tolerationSeconds: 3600

    kubectl get pod -o wide

  • 相关阅读:
    ansible-playbook最佳实践
    zabbix 优化之 表分区
    ansible-playbook 打通ssh无秘钥
    jQuery 1.9 移除了 $.browser 的替代方法
    也谈前端基础设施建设
    滚动视差网站欣赏
    css常见的快捷开发代码汇总(长期更新)
    如何让搜索引擎抓取AJAX内容?
    Bookmarklet编写指南
    20个网页设计师应该学习的CSS3经典教程实例
  • 原文地址:https://www.cnblogs.com/litzhiai/p/14971839.html
Copyright © 2020-2023  润新知