<p>I have a Kubernetes cluster with 3 nodes. On this cluster, there is one Kubernetes StatefulSet that is responsible for receiving messages, persisting the messages, and scheduling the received messages and an application processor of type Deployment that has 3 instances (replicas), ​Here the App Processor POD is receiving multiple kinds of messages from Message Processor POD using REST calls. <br/>
So finally I have</p>
<pre><code>message-processor-0
</code></pre>
<p>and</p>
<pre><code>app-processor-12345
app-processor-23456
app-processor-45567
</code></pre>
<p>Here my requirement is, I want to send particular types of messages to​ only one dedicated instance of the App Processor.</p>

Ashok Kumar
<p>Since you are using a deployment, that specific POD has no reliable network identity. A POD's name and IP address will change whenever it is killed and recreated.</p>
<p>You have two options. One is to create a brand-new deployment and service for that particular pod, so you can communicate with that pod using the newly created service.</p>
<p>Otherwise StatefulSets are another choice, as they have a persistent network identity regardless of whether the POD is killed or restarted.</p>
<p>The StatefulSet pods get fixed ordered names, which will be in the format $(statefulset name)-$(ordinal).</p>
<p>For example if your yaml looks like this:</p>
<pre><code>---
apiVersion: v1
kind: Service
metadata:
  name: testservice
  namespace: testnamespace
  labels:
    app: testapp
spec:
  ports:
    - port: 80
      name: http
  type: ClusterIP
  selector:
    app: myapp
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: testapp
  namespace: testnamespace
spec:
  serviceName: testservice
  replicas: 5
  selector:
    matchLabels:
      app: testapp
</code></pre>
<p>The names of Pods will be testapp-0, testapp-1 and so on.</p>
<p>Then you can use:</p>
<p><code>testapp-0.testservice.testnamespace.svc.cluster.local</code> for accessing Pod 0 of testapp StatetefulSet</p>
<p>For more information refer to: <a href="https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/" rel="nofollow noreferrer">StatefulSet Docs</a></p>
