pod亲和性
原创
©著作权归作者所有:来自51CTO博客作者You0tech的原创作品,请联系作者获取转载授权,否则将追究法律责任
查看帮助路径
[root@k8smaster4 ns]# kubectl explain pod.spec.affinity.podAffinity
首个运行Pod的Yaml
[root@k8smaster4 ns]# cat pod-required-affinity-demo-1.yaml
apiVersion: v1
kind: Pod
metadata:
name: pod-first
labels:
app2: myapp2
tier: frontend
spec:
containers:
- name: myapp
image: docker.io/xianchao/tomcat-8.5-jre8:v1
imagePullPolicy: IfNotPresent
nodeName: k8snode5
亲和性运行Pod的Yaml
[root@k8smaster4 ns]# cat pod-required-affinity-demo-2.yaml
apiVersion: v1
kind: Pod
metadata:
name: pod-second
labels:
app: backend
tier: db
spec:
containers:
- name: busybox
image: docker.io/library/busybox:1.28
imagePullPolicy: IfNotPresent
command: ["sh","-c","sleep 3600"]
affinity:
podAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app2
operator: In
values:
- myapp2
topologyKey: disk