<p>I have a statefulset with 5 replica. This means I have pods with name pod-0 .. pod-4.</p>
<p>I want to create 2 service.</p>
<ol>
<li><p>A service that only routes the request to pod-0 ( this is my edit server ) : I know I can achieve this by &quot;statefulset.kubernetes.io/pod-name=pod-0&quot;  in the service selector. This is fine.</p>
</li>
<li><p>A service that routes the request to all remaining nodes excluding pod-0( even if the application scales up and add more instances those new instances needs to be mapped to this service) : I am unable to achieve this.</p>
</li>
</ol>
<p>Any idea on how to achieve the 2nd service ??</p>
<p>Since it is deployed via 1 stateful manifest file , all pods are having same label .</p>

Raj
<p>Thanks for the info . I followed this approach.</p>
<ol>
<li>Created Role + role binding + service account which have rights to update the label.</li>
<li>At the end of the script that I execute using Docker file [CMD] , I installed kubectl and then executed
<em>kubectl label pod ${HOSTNAME} pod-type=${POD_TYPE} --server=kubernetes.default --token=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token) --certificate-authority=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt -n ${POD_NAMESPACE}</em></li>
</ol>
<p>Above env variables I am passing in the statefulsets. It served my purpose.</p>
