Use the following manifest:
apiVersion: apps/v1
kind: Deployment
metadata:
name: deploy-important
namespace: project-tiger
labels:
id: very-important
spec:
replicas: 3
selector:
matchLabels:
id: very-important
template:
metadata:
labels:
id: very-important
spec:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
labelSelector:
- matchExpressions:
- key: id
operator: In
values:
- very-important
topologyKey: "kubernetes.io/hostname"
containers:
- name: container1
image: nginx:1.17.6-alpine
- name: container2
image: kubernetes/pause