<p>I am looking to spin up a specific number of pods that are independent and not load balanced. (The intent is to use these to send and receive certain traffic to and from some external endpoint.) The way I am planning to do this is to create the pods explicitly (yaml snippet as below)</p>

<pre><code>    apiVersion: v1
    kind: Pod
    metadata:
      name: generator-agent-pod-1
      labels:
        app: generator-agent
        version: v1
    spec:
      containers:
        ...
</code></pre>

<p>(In this, the name will be auto-generated as <code>generator-agent-pod-1, generator-agent-pod-2</code>, etc.)</p>

<p>I am then looking to create one service per pod: so essentially, there'll be a <code>generator-agent-service-1, generator-agent-service-2</code>, etc., and so I can then use the service to be able to reach the pod from outside.</p>

<p>I now have two questions:
1. In the service, how do I select a specific pod by name (instead of by labels)? something equivalent to:</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: generator-agent-service-1
  labels:
    app: agent-service
spec:
  type: NodePort
  ports:
  - port: 8085
    protocol: TCP
  selector:
    metadata.name: generator-agent-pod-1
</code></pre>

<p>(This service does not get any endpoints, so the selector is incorrect, I suppose.)</p>

<ol start="2">
<li>Is there a better way to approach this problem (Kubernetes or otherwise)?</li>
</ol>

<p>Thanks!</p>

Srinivas
<p>I think you are using StatefulSet for controlling Pods.
If so, you can use label <code>statefulset.kubernetes.io/pod-name</code> to select pods in a service.</p>
<p>For illustration:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: Service
metadata:
  name: generator-agent-service-1
  labels:
    app: agent-service
spec:
  type: NodePort
  ports:
  - port: 8085
    protocol: TCP
  selector:
    statefulset.kubernetes.io/pod-name: generator-agent-pod-1
</code></pre>
