<p>I wish to deploy a RabbitMQ StatefulSet on EKS, and prevent it from deploying onto nodes running a Jenkins controller. The affinity rules are not working.</p>
<p>The pod selector labels are:</p>
<pre><code>NAME         READY   STATUS              RESTARTS   AGE     IP               NODE                                           NOMINATED NODE   READINESS GATES   LABELS
rabbitmq-0   1/1     Running             0          3m18s   10.x.x.z   ip-10-x-x-x.eu-west-2.compute.internal   &lt;none&gt;           &lt;none&gt;            app.kubernetes.io/component=broker,app.kubernetes.io/instance=rabbitmq,app.kubernetes.io/name=rabbitmq,app=rabbitmq,controller-revision-hash=rabbitmq-f6c7ddfff,statefulset.kubernetes.io/pod-name=rabbitmq-0


NAME                         READY   STATUS    RESTARTS   AGE   IP               NODE                                           NOMINATED NODE   READINESS GATES   LABELS
jenkins-8499877f97-6jvb6     2/2     Running   0          60m   10.x.x.x   ip-10-x-x-x.eu-west-2.compute.internal    &lt;none&gt;           &lt;none&gt;            app.kubernetes.io/component=jenkins,app.kubernetes.io/instance=jenkins,app.kubernetes.io/name=controller,pod-template-hash=8499877f97
</code></pre>
<p>The nodes have selector labels:</p>
<pre><code>node.app/group=apps
</code></pre>
<p>The RabbitMQ affinity rules are:</p>
<pre><code>affinity:
  nodeAffinity:
    requiredDuringSchedulingIgnoredDuringExecution:
      nodeSelectorTerms:
        - matchExpressions: # assign to eks apps node group
            - key: node.app/group
              operator: In
              values:
                - apps
  podAntiAffinity:
    requiredDuringSchedulingIgnoredDuringExecution:
      - labelSelector:
          matchExpressions: # don't assign to a node running jenkins controller
            - key: app.kubernetes.io/name
              operator: In
              values:
                - controller
            - key: app.kubernetes.io/component
              operator: In
              values:
                - jenkins
        topologyKey: kubernetes.io/hostname
</code></pre>
<p>Any tips or pointers would be much appreciated.</p>
<p>#1 When I say the rules are not working, the Rabbit pods are getting placed onto the same nodes as the Jenkins Controller, which is not what is required. There are no errors.</p>

Theo Sweeny
<p>So the above rule do work, but not only had the existing Helm deployment to be deleted, but also the existing deployment PVC and the PV. Once all was cleared down and recreated, the affinity rules started to play ball.</p>
