<p>I was trying to setup Service per Pod in stateful set with metacontroller: <a href="https://github.com/metacontroller/metacontroller/tree/master/examples/service-per-pod" rel="nofollow noreferrer">https://github.com/metacontroller/metacontroller/tree/master/examples/service-per-pod</a></p>
<p>I was following linked instruction, I was playing with various combination, but I still didn't achieve what is described. Services are not created together with pod.</p>
<p>In this example, I was trying to put service-per-pod-label: &quot;web&quot; against the name of the pod.</p>
<pre><code>apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: nginx
  annotations:
    service-per-pod-label: &quot;statefulset.kubernetes.io/pod-name&quot;
    service-per-pod-ports: &quot;80:80&quot;
spec:
  selector:
    matchLabels:
      app: nginx
  serviceName: nginx
  replicas: 3
  template:
    metadata:
      labels:
        app: nginx
    spec:
      terminationGracePeriodSeconds: 1
      containers:
      - name: nginx
        image: gcr.io/google_containers/nginx-slim:0.8
        ports:
        - containerPort: 80
          name: web
</code></pre>
<p>my metacontroller is up and running</p>
<pre><code>NAME                                   READY   STATUS    RESTARTS   AGE
metacontroller-metacontroller-helm-0   1/1     Running   0          23m
</code></pre>
<p>logs from metacontroller:
kubectl logs metacontroller-metacontroller-helm-0</p>
<pre><code>{&quot;level&quot;:&quot;info&quot;,&quot;ts&quot;:1660492483.489682,&quot;msg&quot;:&quot;Configuration information&quot;,&quot;discovery-interval&quot;:20,&quot;cache-flush-interval&quot;:1800,&quot;metrics-address&quot;:&quot;:9999&quot;,&quot;client-go-qps&quot;:5,&quot;client-go-burst&quot;:10,&quot;workers&quot;:5,&quot;events-qps&quot;:0.0033333333333333335,&quot;events-burst&quot;:25,&quot;pprofAddr&quot;:&quot;0&quot;,&quot;leader-election&quot;:false,&quot;leader-election-resource-lock&quot;:&quot;leases&quot;,&quot;leader-election-namespace&quot;:&quot;&quot;,&quot;leader-election-id&quot;:&quot;metacontroller&quot;,&quot;version&quot;:&quot;4.3.4&quot;}
{&quot;level&quot;:&quot;info&quot;,&quot;ts&quot;:1660492483.5292923,&quot;msg&quot;:&quot;Communication with K8s API server successful&quot;}
{&quot;level&quot;:&quot;info&quot;,&quot;ts&quot;:1660492484.7299764,&quot;msg&quot;:&quot;Waited for 1.19273971s due to client-side throttling, not priority and fairness, request: GET:https://10.3.0.1:443/apis/authorization.k8s.io/v1?timeout=32s\n&quot;}
{&quot;level&quot;:&quot;info&quot;,&quot;ts&quot;:1660492489.1358352,&quot;logger&quot;:&quot;controller-runtime.metrics&quot;,&quot;msg&quot;:&quot;Metrics server is starting to listen&quot;,&quot;addr&quot;:&quot;:9999&quot;}
{&quot;level&quot;:&quot;info&quot;,&quot;ts&quot;:1660492489.1373081,&quot;msg&quot;:&quot;Starting EventSource&quot;,&quot;controller&quot;:&quot;composite-metacontroller&quot;,&quot;source&quot;:&quot;kind source: *v1alpha1.CompositeController&quot;}
{&quot;level&quot;:&quot;info&quot;,&quot;ts&quot;:1660492489.1373482,&quot;msg&quot;:&quot;Starting Controller&quot;,&quot;controller&quot;:&quot;composite-metacontroller&quot;}
{&quot;level&quot;:&quot;info&quot;,&quot;ts&quot;:1660492489.1376293,&quot;msg&quot;:&quot;Starting EventSource&quot;,&quot;controller&quot;:&quot;decorator-metacontroller&quot;,&quot;source&quot;:&quot;kind source: *v1alpha1.DecoratorController&quot;}
{&quot;level&quot;:&quot;info&quot;,&quot;ts&quot;:1660492489.1376536,&quot;msg&quot;:&quot;Starting Controller&quot;,&quot;controller&quot;:&quot;decorator-metacontroller&quot;}
{&quot;level&quot;:&quot;info&quot;,&quot;ts&quot;:1660492489.1371636,&quot;msg&quot;:&quot;Starting server&quot;,&quot;path&quot;:&quot;/metrics&quot;,&quot;kind&quot;:&quot;metrics&quot;,&quot;addr&quot;:&quot;[::]:9999&quot;}
{&quot;level&quot;:&quot;info&quot;,&quot;ts&quot;:1660492489.2376945,&quot;msg&quot;:&quot;Starting workers&quot;,&quot;controller&quot;:&quot;composite-metacontroller&quot;,&quot;worker count&quot;:1}
{&quot;level&quot;:&quot;info&quot;,&quot;ts&quot;:1660492489.2379737,&quot;msg&quot;:&quot;Starting workers&quot;,&quot;controller&quot;:&quot;decorator-metacontroller&quot;,&quot;worker count&quot;:1}
{&quot;level&quot;:&quot;info&quot;,&quot;ts&quot;:1660492494.7370083,&quot;msg&quot;:&quot;Waited for 5.587625994s due to client-side throttling, not priority and fairness, request: GET:https://10.3.0.1:443/apis/networking.k8s.io/v1?timeout=32s\n&quot;}
{&quot;level&quot;:&quot;info&quot;,&quot;ts&quot;:1660492510.3382494,&quot;msg&quot;:&quot;Waited for 1.165526209s due to client-side throttling, not priority and fairness, request: GET:https://10.3.0.1:443/apis/flowcontrol.apiserver.k8s.io/v1beta2?timeout=32s\n&quot;}
</code></pre>

korallo
<p>As explained in the documentation, for Kubernetes 1.9+, your <code>service-per-pod-label</code> should have <code>&quot;statefulset.kubernetes.io/pod-name&quot;</code> as value:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: nginx
  annotations:
    service-per-pod-label: &quot;statefulset.kubernetes.io/pod-name&quot;
    service-per-pod-ports: &quot;80:80&quot;
spec:
  selector:
    matchLabels:
      app: nginx
  serviceName: nginx
  replicas: 3
  template:
    metadata:
      labels:
        app: nginx
    spec:
      terminationGracePeriodSeconds: 1
      containers:
      - name: nginx
        image: gcr.io/google_containers/nginx-slim:0.8
        ports:
        - containerPort: 80
          name: web
</code></pre>
<p>And for earlier versions, you should add the annotation <code>pod-name-label: &quot;pod-name&quot;</code> for your pod`:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: nginx
  annotations:
    service-per-pod-label: &quot;pod-name&quot;
    service-per-pod-ports: &quot;80:80&quot;
spec:
  selector:
    matchLabels:
      app: nginx
  serviceName: nginx
  replicas: 3
  template:
    metadata:
      labels:
        app: nginx
      annotations:
        pod-name-label: &quot;pod-name&quot;
    spec:
      terminationGracePeriodSeconds: 1
      containers:
      - name: nginx
        image: gcr.io/google_containers/nginx-slim:0.8
        ports:
        - containerPort: 80
          name: web
</code></pre>
<p>In the two cases, you should use the term <code>pod-name</code>, and not another value. They use it to know the name they should use for the created services.</p>
