<p>Is there a way to tell Kubernetes to never run two pods on the same node, an example I have two pods replicas, I want them to be always distributed over <code>zone1/zone2</code> and never in the same zone together.</p>

<pre><code>apiVersion: app/v1
kind: Deployment
metadata:
  name: testApp
  labels:
    app: testApp-front
  namespace: 
spec:
  replicas: 2
  selector:
    matchLabels:
      app: testApp-front
  template:
    metadata:
      labels:
        app: testApp-front
    spec:      
      nodeSelector:
        failure-domain.beta.kubernetes.io/zone: zone1
</code></pre>

Dady
<p>Seems like it can be done with Interpod Affinity you can see : </p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: web-server
spec:
  selector:
    matchLabels:
      app: testApp-front
  replicas: 3
  template:
    metadata:
      labels:
        app: testApp-front
    spec:
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
          - labelSelector:
              matchExpressions:
              - key: app
                operator: In
                values:
                - testApp-front
            topologyKey: "kubernetes.io/hostname"
        podAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
          - labelSelector:
              matchExpressions:
              - key: app
                operator: In
                values:
                - store
            topologyKey: "kubernetes.io/hostname"
      containers:
      - name: web-testApp-front
        image: nginx:1.12-alpine
</code></pre>

<p>you can see the full <a href="https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#inter-pod-affinity-and-anti-affinity-beta-feature" rel="nofollow noreferrer">example here</a></p>
