<p>I have k8s cluster with 3 nodes </p>

<p>I would like that a sample deployment with 3 replicas as the follwing , so each pod got schduled in a different node ?</p>

<pre><code>apiVersion: apps/v1 kind: Deployment metadata:   name: tomcat-deployment   labels:
    app: tomcat spec:   replicas: 3   selector:
    matchLabels:
      app: tomcat   template:
    metadata:
      labels:
        app: tomcat
    spec:
      containers:
      - name: tomcat
        image: tomcat:9.0
        ports:
        - containerPort: 80
</code></pre>

<p>You can use podAntiAffinity to make sure that the same pods of a deployment should never run on the same node(depends on topology). Check the following document <a href="https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/" rel="noreferrer">Assigning Pods to Nodes</a>.</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: tomcat-deployment
  labels:
    app: tomcat
spec:
  replicas: 3
  selector:
    matchLabels:
      app: tomcat
  template:
    metadata:
      labels:
        app: tomcat
    spec:
      containers:
      - name: tomcat
        image: tomcat:9.0
        ports:
        - containerPort: 80
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
          - labelSelector:
              matchExpressions:
              - key: "app"
                operator: In
                values:
                - tomcat
            topologyKey: "kubernetes.io/hostname"
</code></pre>
