<p>I'm having trouble using nodeAntiAffinity... in my use case I need to prevent the instances of a StatefulSet running on the same node, and that's it. I don't have labels for my nodes, which the doc looks to list as a requirement. Is it possible to purely rely on unique values of the built in label "kubernetes.io/hostname"?</p>

<p>What I am trying to do in my StatefulSet:</p>

<pre><code>spec:
  podManagementPolicy: OrderedReady
  affinity:
    nodeAntiAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        topologyKey: "kubernetes.io/hostname"
</code></pre>

<p>What the examples in the doc say I have to do:</p>

<pre><code>spec:
  podManagementPolicy: OrderedReady
  affinity:
    nodeAntiAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:
        - matchExpressions:
            - key: &lt;some key&gt;
              operator: In
              values:
                - &lt;some value&gt;
        topologyKey: "kubernetes.io/hostname"
</code></pre>

user797963
<p>To prevent the instances of a StatefulSet running on the same node, you need a podAntiAffinity, excerpt from zookeeper tutorial of <a href="https://kubernetes.io/docs/tutorials/stateful-application/zookeeper/" rel="nofollow noreferrer">Kubernetes document</a> :</p>

<pre><code>  affinity:
    podAntiAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        - labelSelector:
            matchExpressions:
              - key: "app"
                operator: In
                values:
                - zk
          topologyKey: "kubernetes.io/hostname"
</code></pre>
