首页 技术 正文
技术 2022年11月6日
0 收藏 770 点赞 392 浏览 1979 个字
  • 通过标签绑定
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容忍污点

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,487
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,903
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,736
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,487
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,127
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,289