pod亲和性(Affinity)清单
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-deployment
namespace: test
spec:
replicas: 1
selector:
matchLabels:
environment: stg
template:
metadata:
labels:
environment: stg
spec:
containers:
- name: nginx-container
image: nginx:latest
imagePullPolicy: IfNotPresent
ports:
- name: nginx-port
containerPort: 80
protocol: TCP
lifecycle:
postStart:
exec:
command: ["/bin/sh","-c","echo jiayouba!!!!!>/usr/share/nginx/html/index.html"]
affinity: #亲和性设置
podAffinity: #设置pod亲和性
requiredDuringSchedulingIgnoredDuringExecution: #硬限制
- labelSelector:
matchExpressions: # 匹配env的值在["xxx","yyy"]中的标签
- key: podenv
operator: In
values: ["xxx","yyy"]
topologyKey: kubernetes.io/hostname
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-deployment
namespace: test
spec:
replicas: 1
selector:
matchLabels:
environment: stg
template:
metadata:
labels:
environment: stg
spec:
containers:
- name: nginx-container
image: nginx:latest
imagePullPolicy: IfNotPresent
ports:
- name: nginx-port
containerPort: 80
protocol: TCP
lifecycle:
postStart:
exec:
command: ["/bin/sh","-c","echo jiayouba!!!!!>/usr/share/nginx/html/index.html"]
affinity: #亲和性设置
podAffinity: #设置pod亲和性
preferredDuringSchedulingIgnoredDuringExecution: #软限制
- weight: 1
podAffinityTerm:
labelSelector:
matchExpressions: # 匹配env的值在["xxx","yyy"]中的标签
- key: podenv
operator: In
values: ["xxx","yyy"]
topologyKey: kubernetes.io/hostname
本文来自博客园,作者:弩哥++,转载请注明原文链接:https://www.cnblogs.com/bangbangzoutianya/p/16851840.html