博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
k8s 高级调度 亲和力和反亲和力、绑定标签、污点容忍污点
阅读量:2228 次
发布时间:2019-05-09

本文共 2616 字,大约阅读时间需要 8 分钟。

  • 通过标签绑定 
spec:  nodeSelector:    bigdata-node: bigdata  containers:    - env:

pod只能运行在有bigdata-node: bigdata 标签的node节点

  • 通过node name绑定
spec:  nodeName: test-oc08  containers:    - env:

pod只能运行在名为test-oc08节点上

 

  • node的亲和力
apiVersion: v1kind: Podmetadata:  name: with-node-affinityspec:  affinity:    nodeAffinity:  #节点选择      requiredDuringSchedulingIgnoredDuringExecution: #定义必要规则        nodeSelectorTerms:        - matchExpressions:          - key: e2e-az-NorthSouth  #必须匹配的键/值对(标签)            operator: In             values:            - e2e-az-North #必须匹配的键/值对(标签            - e2e-az-South   containers:  - name: with-node-affinity    image: docker.io/ocpqe/hello-pod

该规则要求将pod放置在节点上,且节点的标签的关键字是e2e-az-NorthSouth,其值是e2e-az-North或者e2e-az-South

apiVersion: v1kind: Podmetadata:  name: with-node-affinityspec:  affinity:    nodeAffinity:       preferredDuringSchedulingIgnoredDuringExecution: #定义首选规则      - weight: 1  #权重        preference:          matchExpressions:          - key: e2e-az-EastWest             operator: In             values:            - e2e-az-East             - e2e-az-West   containers:  - name: with-node-affinity    image: docker.io/ocpqe/hello-pod

该节点具有标签的关键字为e2e-az-EastWest且其值为e2e-az-East或者e2e-az-West是该Pod的首选项的节点

  •  pod间亲和性和反亲和性
apiVersion: v1kind: Podmetadata:  name: with-pod-affinityspec:  affinity:    podAffinity: #亲和性      requiredDuringSchedulingIgnoredDuringExecution:       - labelSelector:          matchExpressions:          - key: security             operator: In             values:            - S1         topologyKey: failure-domain.beta.kubernetes.io/zone  containers:  - name: with-pod-affinity    image: docker.io/ocpqe/hello-pod

pod必须部署在一个节点上,这个节点上至少有一个正在运行的pod,这个pod中security=S1

apiVersion: v1kind: Podmetadata:  name: with-pod-antiaffinityspec:  affinity:    podAntiAffinity: #反亲和性      preferredDuringSchedulingIgnoredDuringExecution:       - weight: 100         podAffinityTerm:          labelSelector:            matchExpressions:            - key: security               operator: In               values:              - S2           topologyKey: kubernetes.io/hostname  containers:  - name: with-pod-affinity    image: docker.io/ocpqe/hello-pod

pod不太会部署在一个节点上,这个节点上正在运行的pod中有security=S2

  • node的污点和

NoSchedule  #新pod不会被调到该节点,已经存在的pod不会影响

PreferNoSchedule #新pod尽量避免不会调度到该节点,已经存在的pod不会影响

NoExecute  #新pod不会被调到该节点,已经存在的pod将会被删除

spec:  taints:  - effect: NoSchedule    key: key1    timeAdded: null    value: value1

给节点添加污点

spec:  tolerations:  - key: "key1"    operator: "Equal"    value: "value1"    effect: "NoSchedule"

pod容忍污点

转载于:https://www.cnblogs.com/37yan/p/8673292.html

你可能感兴趣的文章
【操作系统】系统调用的概念
查看>>
【计算机网络】cookie和session的区别
查看>>
【C++】构造函数、析构函数抛出异常的问题
查看>>
【C++】关于vector<bool>
查看>>
【操作系统】内存碎片产生原因及终极解决办法
查看>>
幂等性验证思想
查看>>
DB理论--数据存储方式
查看>>
PB协议的说明与使用
查看>>
什么是TPS,什么是QPS,区别是什么?
查看>>
git pull遇到错误:error: Your local changes to the following files would be overwritten by merge:
查看>>
arraylist扩容时机java8
查看>>
logback中additivity的理解
查看>>
一篇文章搞懂hash,hashcode,equals,==的用法
查看>>
mysql数据库,悲观锁。for update 的用法。
查看>>
springboot+jta+atomikos多数据源和 springboot+mybatisplus+aop实现数据库读写分离而引发的一些思考
查看>>
java面试中常考的一些面试sql语句
查看>>
一个字节等于多少位?
查看>>
帧框架frameset的用法总结
查看>>
java1.8中创建hashmap的初始化大小设置标准
查看>>
mark一下,service的实现层没有加@service注解。
查看>>