<p>I want to create nodegroup selector which contain only primary pod and exclude backup pod in kubernates. How to achieve that using helm chart ?</p>
<pre><code>appVersion: version1
kind: StatefulSet
metadata: 
  name: statefulname
  label: 
    ....
    ....
    ....
spec:
  replica: 2

  .....
 container:
   .....
   ....
   nodeselecor:
    {{$nodegroup}}
</code></pre>
<p>here result is</p>
<pre><code> NAME                    READY   STATUS    STARTS   AGE
pod/zookeeper-np-0       1/1     Running   0        203s
pod/zookeeper-np-1       1/1     Running   0        137s
</code></pre>
<p>here replica create 2 instance of pod with suffix -0 and -1 and both have same node selector but i want to that for
<code>pod/zookeeper-np-0 </code> for this node selector is node group ng1
<code>pod/zookeeper-np-1 </code> for this node selector is node group ng2</p>
<p>i tried with iterate also not getting error</p>
<pre><code>Caused By: java.lang.IllegalStateException: Identified another participant with the same name for Space: newspace_container_newspace
</code></pre>

Mystery Girl
<p>You have not shared the K8s version details however you can look for the using the <strong>Node affinity</strong> with <strong>statefulset</strong> or else <strong>topologySpreadConstraints</strong></p>
<pre><code>topologySpreadConstraints:
    - maxSkew: &lt;integer&gt;
      topologyKey: &lt;string&gt;
      whenUnsatisfiable: &lt;string&gt;
      labelSelector: &lt;object&gt;
</code></pre>
<p>Read more at : <a href="https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/</a></p>
<p>using the <strong>topologySpreadConstraints</strong> you can spread the PODs across the nodes.</p>
<p><strong>Node Affinity</strong></p>
<pre><code>nodeAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:
        - matchExpressions:
          - key: kubernetes.io/e2e-az-name
            operator: In
            values:
            - e2e-az1
            - e2e-az2
</code></pre>
<p>Read more : <a href="https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/</a></p>
<p>You can also use the node affinity to do the same scheduling the PODs on different nodes.</p>
