Only peaks-node-2 and peaks-node-3 carry a zone label. Apply a Deployment that requires a zone and prefers the west:
sh
kubectl apply -n peaks-1fx16jj -f - <<EOF
apiVersion: apps/v1
kind: Deployment
metadata:
name: market-api
spec:
replicas: 3
selector:
matchLabels:
app: market-api
template:
metadata:
labels:
app: market-api
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: zone
operator: In
values: [east, west]
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
preference:
matchExpressions:
- key: zone
operator: In
values: [west]
containers:
- name: api
image: stackmonsters/monster-market-api
EOF
kubectl get pods -n peaks-1fx16jj -o wideThen drain the preference of its power: cordon peaks-node-3 and scale to 5. The two new replicas still have to obey the required rule.
sh
kubectl cordon peaks-node-3
kubectl scale deploy market-api --replicas=5 -n peaks-1fx16jj
kubectl get pods -n peaks-1fx16jj -o wide