k8s 高级调度 亲和力和反亲和力、绑定标签、污点容忍污点
- 通过标签绑定
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: v1
kind: Pod
metadata:
name: with-node-affinity
spec:
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: v1
kind: Pod
metadata:
name: with-node-affinity
spec:
affinity:
nodeAffinity:
preferredDuringSchedulingIgnoredDuringExecution: #定义首选规则
- weight: #权重
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: v1
kind: Pod
metadata:
name: with-pod-affinity
spec:
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: v1
kind: Pod
metadata:
name: with-pod-antiaffinity
spec:
affinity:
podAntiAffinity: #反亲和性
preferredDuringSchedulingIgnoredDuringExecution:
- weight:
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容忍污点
k8s 高级调度 亲和力和反亲和力、绑定标签、污点容忍污点的更多相关文章
- 从零开始入门 K8s | Kubernetes 调度和资源管理
作者 | 子誉 蚂蚁金服高级技术专家 关注"阿里巴巴云原生"公众号,回复关键词"入门",即可下载从零入门 K8s 系列文章 PPT. Kubernetes 调 ...
- K8S 高级调度方式
可以使用高级调度分为: 节点选择器: nodeSelector.nodeName 节点亲和性调度: nodeAffinity Pod亲和性调度:PodAffinity Pod反亲和性调度:podAnt ...
- k8s之调度器、预选策略及优选函数
1.调度器(scheduler) 调度器的功能是调度Pod在哪个Node上运行,这些调度信息存储在master上的etcd里面,能够和etcd打交道的只有apiserver; kubelet运行在no ...
- 9.深入k8s:调度器及其源码分析
转载请声明出处哦~,本篇文章发布于luozhiyun的博客:https://www.luozhiyun.com 源码版本是1.19 这次讲解的是k8s的调度器部分的代码,相对来说比较复杂,慢慢的梳理清 ...
- Kubernetes高级调度- Taint和Toleration、Node Affinity分析
此文分享了污点和Node Affinity实际使用过程中的细节.坑和思维误区.同时整理且回答了诸多细节问题,尤其那些在官方文档中不曾提及的细节. 阅读提示:文中的节点指Node (避免Pod和Node ...
- Kubernetes K8S之调度器kube-scheduler详解
Kubernetes K8S之调度器kube-scheduler概述与详解 kube-scheduler调度概述 在 Kubernetes 中,调度是指将 Pod 放置到合适的 Node 节点上,然后 ...
- k8s核心资源之namespace与pod污点容忍度生命周期进阶篇(四)
目录 1.命名空间namespace 1.1 什么是命名空间? 1.2 namespace应用场景 1.3 namespacs常用指令 1.4 namespace资源限额 2.标签 2.1 什么是标签 ...
- Kubernetes K8S之affinity亲和性与反亲和性详解与示例
Kubernetes K8S之Node节点亲和性与反亲和性以及Pod亲和性与反亲和性详解与示例 主机配置规划 服务器名称(hostname) 系统版本 配置 内网IP 外网IP(模拟) k8s-mas ...
- k8s之调度约束
k8s调度约束有两种:第一种,直接指定某台node主机:这种形势将直接跳过调度器.如下: 第二种:先给各node指定标签,然后在通过标签的形势来关联node,这种形势人就会调用到调度器.如下: yao ...
随机推荐
- E - TOYS
来源 poj 2318 Calculate the number of toys that land in each bin of a partitioned toy box. Mom and dad ...
- java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=...) with your test
写了一个单元测试test来启动activiti,controller放在src/main/java根目录下,test对应也放在src/test/java下,结果报错: java.lang.Illega ...
- Codeforces 660C - Hard Process - [二分+DP]
题目链接:http://codeforces.com/problemset/problem/660/C 题意: 给你一个长度为 $n$ 的 $01$ 串 $a$,记 $f(a)$ 表示其中最长的一段连 ...
- [No0000161]IDEA初步接触
安装 参考https://blog.csdn.net/qq_35246620/article/details/61191375 安装过程全程默认(路径和快捷方式自定义,不需要下载jre): 启动后全程 ...
- Flash and Scalform CLIK
Flash shift + f7 打开组件检查面板 Scaleform As bit define bool Unrolling :1; // indi ...
- 为单实例数据库配置ASM
环境配置沿用搭建RAC的环境配置 配置ASM可以在数据库软件安装之前进行,也可以在安装完数据库软件配置数据库前进行 [root@rac01 Packages]# cd /etc/yum.repos.d ...
- LeetCode 728 Self Dividing Numbers 解题报告
题目要求 A self-dividing number is a number that is divisible by every digit it contains. For example, 1 ...
- You-Get——基于Python3的媒体下载工具
You-Get是一个基于 Python 3 的下载工具.使用 You-Get 可以很轻松的下载到网络上的视频.图片及音乐. 项目主页:https://github.com/soimort/you-ge ...
- 洛谷P4247 序列操作 [清华集训] 线段树
正解:线段树 解题报告: 传送门! 通过这题我get了一个神奇的,叫,线段树五问的东西hhhh 听起来有点中二但感觉真正做题的时候还是比较有用的,,,?感觉会让条理清晰很多呢,所以放一下QwQ →每个 ...
- LeetCode-860. Lemonade Change
At a lemonade stand, each lemonade costs $5. Customers are standing in a queue to buy from you, and ...