强制
kind: Deployment
apiVersion: apps/v1
metadata:
name: springboot-web-app1
labels:
k8s-app: springboot-web-app1
spec:
replicas: 5
template:
spec:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: k8s-app
operator: In
values:
- springboot-web-app1
topologyKey: kubernetes.io/hostname
尽量
kind: Deployment
apiVersion: apps/v1
metadata:
name: springboot-web-app1
labels:
k8s-app: springboot-web-app1
spec:
replicas: 5
template:
spec:
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
matchExpressions:
- key: k8s-app
operator: In
values:
- springboot-web-app1
topologyKey: kubernetes.io/hostname
|