Cloud Native应用交付

  • 首页
  • 关于本站
  • 个人介绍
  • Downloads
  • Repo
    • Github
    • Container
  • F5
    • F5 In AI Agent Arch
    • F5 AI Infrastructure Blueprint
    • F5 Python SDK
    • F5-container
    • F5-LBaaS
  • 社交
    • 联系我
    • 微信/微博
    • 公众号
    • 打赏赞助
行至水穷处 坐看云起时
Cloud Native Application Services: cnadn.net
  1. 首页
  2. 容器/k8s
  3. 正文

Node Affinity / Taints /Tolerations

2018年08月11日 9271点热度 0人点赞 0条评论

Warning: Array to string conversion in /home/wwwroot/myf5/wp-content/plugins/wpjam-basic/public/wpjam-utils.php on line 458
[root@k8s-master cka]# cat multi-expression-in-term.yaml
apiVersion: v1
kind: Pod
metadata:
  name: node-affinity-allmatch
spec:
  affinity:
    nodeAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:
        - matchExpressions:
          - key: role
            operator: In
            values:
             - master
          - key: role
            operator: In
            values:
             - node
  containers:
  - name: with-node-affinity
    image: nginx

 Warning   FailedScheduling   default-scheduler    0/2 nodes are available: 2 node(s) didn't match node selector.

在一个matchexpression部分中的多条件是 AND关系


[root@k8s-master cka]# cat multi-terms.yaml
apiVersion: v1
kind: Pod
metadata:
  name: node-affinity-ifany
spec:
  affinity:
    nodeAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:
        - matchExpressions:
          - key: role
            operator: In
            values:
             - master
        - matchExpressions:
          - key: role
            operator: In
            values:
             - node
  containers:
  - name: with-node-affinity
    image: nginx

多nodeselectorterm是 或,任意一个匹配即可


[root@k8s-master cka]# cat prefer-affinity.yaml
apiVersion: v1
kind: Pod
metadata:
  name: node-affinity-ifany
spec:
  affinity:
    nodeAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:
        - matchExpressions:
          - key: owner
            operator: In
            values:
             - lj
      preferredDuringSchedulingIgnoredDuringExecution:
      - weight: 10
        preference:
          matchExpressions:
          - key: role
            operator: In
            values:
             - node
  containers:
  - name: with-node-affinity
    image: nginx

2018-08-11 13:17:44 +0800 CST   2018-08-11 13:17:44 +0800 CST   1         node-affinity-ifany.1549bcbc3b670aef   Pod                 Normal    Scheduled   default-scheduler   Successfully assigned node-affinity-ifany to k8s-node1
2018-08-11 13:17:45 +0800 CST   2018-08-11 13:17:45 +0800 CST   1         node-affinity-ifany.1549bcbc733d4529   Pod                 Normal    SuccessfulMountVolume   kubelet, k8s-node1   MountVolume.SetUp succeeded for volume "default-token-gt88m"
2018-08-11 13:17:47 +0800 CST   2018-08-11 13:17:47 +0800 CST   1         node-affinity-ifany.1549bcbcd5bfb3af   Pod       spec.containers{with-node-affinity}   Normal    Pulling   kubelet, k8s-node1   pulling image "nginx"
2018-08-11 13:17:55 +0800 CST   2018-08-11 13:17:55 +0800 CST   1         node-affinity-ifany.1549bcbecd747893   Pod       spec.containers{with-node-affinity}   Normal    Pulled    kubelet, k8s-node1   Successfully pulled image "nginx"
2018-08-11 13:17:55 +0800 CST   2018-08-11 13:17:55 +0800 CST   1         node-affinity-ifany.1549bcbeda6e3ece   Pod       spec.containers{with-node-affinity}   Normal    Created   kubelet, k8s-node1   Created container
2018-08-11 13:17:56 +0800 CST   2018-08-11 13:17:56 +0800 CST   1         node-affinity-ifany.1549bcbee47f163c   Pod       spec.containers{with-node-affinity}   Normal    Started   kubelet, k8s-node1   Started container

required首先要满足,在同时多个node满足的情况下,使用prefer,preference下只能配置一个matchexpression,如果匹配则给node加weight(因为此时scheduler还需根据很多其它条件来排序可用的nodes,增加分值可以增加选择概率)


Taints, 用在node上,格式为key=value:effect,例如

edge=true:NoSchedule
gpu=true:NoSchedule
bigdata=true:NoExcute
dev=team3:PreferNoSschedule
最后的effect指明了这个taint的动作,拒绝被调度,拒绝pod在其上执行,不优先考虑被调度。如果一个node有了Noschedule的taint,那么只有当pod声明了对应的key/value/effect的tolerations时,这个pod才可以被调度到这个node上。

所以这个方法一般用来保护一个node,确保node上只调度那些期望的pods。

一个node包含多个taints,tolerations会挨个根据自己的tolerations去匹配过滤,都能被toleration了就可以调度,如果有剩余的taints没被匹配,那么根据这个剩余的taints本身的效果来决定。

tolerations:
- key: "key"
  operator: "Exists" 匹配key的任意effect都可以被容忍
tolerations:
- operator: "Exists"
表示容忍所有。 Existsccc操作本身不需要配置value
Array
本作品采用 知识共享署名-非商业性使用 4.0 国际许可协议 进行许可
标签: affinity k8s taints toleration 亲和
最后更新:2018年08月11日

纳米

linjing.io

打赏 点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理。

页面AI聊天助手

纳米

linjing.io

☁️迈向Cloud Native ADC ☁️

认证获得:
TOGAF: ID 152743
Kubernetes: CKA #664
Microsoft: MCSE MCDBA
Cisco: CCNP
Juniper: JNCIS
F5:
F5 Certified Solution Expert, Security
F5 Certified Technology Specialist, LTM/GTM/APM/ASM
F5 Certified BIG-IP Administrator
  • 点击查看本博技术要素列表
  • 归档
    分类
    • AI
    • Automation
    • Avi Networks
    • Cisco ACI
    • CISCO资源
    • F5 with ELK
    • F5-Tech tips
    • F5技术
    • Juniper
    • Linux
    • NGINX
    • SDN
    • ServiceMesh
    • WEB编程
    • WINDOWS相关
    • 业界文章
    • 交换机技术
    • 化云为雨/Openstack
    • 协议原理
    • 容器/k8s
    • 我的工作
    • 我的生活
    • 网站技术
    • 路由器技术
    • 项目案例
    标签聚合
    bigip gtm neutron openstack api network flannel F5 envoy DNS istio docker nginx irule k8s
    最近评论
    纳米 发布于 2 周前(11月08日) 这文件是独立密码,需要的联系
    纳米 发布于 2 周前(11月08日) 这几个是独立密码。需要的话联系。
    Abeny 发布于 9 个月前(02月20日) Very good!
    李成才 发布于 1 年前(06月03日) 大佬公众号里查的下载密码都不对呢
    李成才 发布于 2 年前(04月09日) 大佬,F5排错培训材料,ssl培训这几个新的材料下载密码不对呢,已关注公众号获取下载密码
    浏览次数
    • Downloads - 198,229 views
    • 联系我 - 139,125 views
    • 迄今为止最全最深入的BIGIP-DNS/GTM原理及培训资料 - 129,523 views
    • Github - 116,408 views
    • Sniffer Pro 4 70 530抓包软件 中文版+视频教程 - 93,633 views
    • 迄今为止最全最深入的BIGIP-DNS/GTM原理及培训资料 - 91,903 views
    • F5常见log日志解释 - 91,306 views
    • 从传统ADC迈向CLOUD NATIVE ADC - 下载 - 90,014 views
    • 关于本站 - 78,712 views
    • F5利用Elastic stack(ELK)进行应用数据挖掘系列(2)-DNS - 65,823 views
    链接表
    • F5SE创新
    • Jimmy Song‘s Blog
    • SDNlab
    • Service Mesh社区
    • 三斗室
    • 个人profile
    • 云原生社区

    COPYRIGHT © 2023 Cloud Native 应用交付. ALL RIGHTS RESERVED.

    Theme Kratos Made By Seaton Jiang

    京ICP备14048088号-1

    京公网安备 11010502041506号