<p>I have a simple StatefulSet here that has <code>replicas = 2</code> but it's creating 4 pods:</p>
<pre><code>service-0
service-1
service-bf28b090c-0
service-44adf4asd-0
</code></pre>
<p>statefulset.yaml</p>
<pre><code>apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: service
  namespace: {{ .Release.Namespace }}
  labels:
    app: service
    tier: web
spec:
  serviceName: service
  replicas: 2
  selector:
    matchLabels:
      app: service
      tier: web
[...]
</code></pre>
<p>Can someone help me wrap my head around that?</p>

CC BY-SA 4.0
2023-12-19T13:08:20.197Z
Very weird indeed. Can you check for any `Deployment` or `DaemonSet` ressource across all namespaces ? In my opinion the `service-bf28b090c-0` and `service-44adf4asd-0` are not part of the `StatefulSet` you created above since their naming do not respect the convention (see https://kubernetes.io/docs/tutorials/stateful-application/basic-stateful-set/#examining-the-pod-s-ordinal-index). Can you check if they also have the label `statefulset.kubernetes.io/pod-name` ? Otherwise they might be Pods you manually deployed for some reason, or remainders from previous stuff.
ABWassim
CC BY-SA 4.0
2023-12-20T12:43:45.193Z
Can you elaborate on the naming convention? The service-0 and service-1 seem to be compliant with this convention. I deleted all the manifests/helm releases from the cluster and redeploy the very same StatefulSet and it does the same thing. I think it's a bug with Openshift TBH...
martin8768
CC BY-SA 4.0
2023-12-20T14:37:21.890Z
Indeed, `service-0` and `service-1` are compliant to the convention, which is why my guess is that the `service-bf28b090c-0` and `service-44adf4asd-0` are the extras. When you delete the `service` StatefulSet, do these Pods disappear ?
ABWassim
<kubernetes><helm><kubernetes-helm>
Statefulset is creating more pods than expected
martin8768
# Statefulset is creating more pods than expected

(Asked by: username_0 on 2023-12-15)

I have a simple StatefulSet here that has replicas = 2 but it's creating 4 pods:
service-0
service-1
service-bf28b090c-0
service-44adf4asd-0

statefulset.yaml
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: service
  namespace: {{ .Release.Namespace }}
  labels:
    app: service
    tier: web
spec:
  serviceName: service
  replicas: 2
  selector:
    matchLabels:
      app: service
      tier: web
[...]

Can someone help me wrap my head around that?

**Tags:** kubernetes, helm, kubernetes-helm

> **Comments:**
> **username_1**: Very weird indeed. Can you check for any `Deployment` or `DaemonSet` ressource across all namespaces ? In my opinion the `service-bf28b090c-0` and `service-44adf4asd-0` are not part of the `StatefulSet` you created above since their naming do not respect the convention (see https://kubernetes.io/docs/tutorials/stateful-application/basic-stateful-set/#examining-the-pod-s-ordinal-index). Can you check if they also have the label `statefulset.kubernetes.io/pod-name` ? Otherwise they might be Pods you manually deployed for some reason, or remainders from previous stuff.  
> **username_0**: Can you elaborate on the naming convention? The service-0 and service-1 seem to be compliant with this convention. I deleted all the manifests/helm releases from the cluster and redeploy the very same StatefulSet and it does the same thing. I think it's a bug with Openshift TBH...  
> **username_1**: Indeed, `service-0` and `service-1` are compliant to the convention, which is why my guess is that the `service-bf28b090c-0` and `service-44adf4asd-0` are the extras. When you delete the `service` StatefulSet, do these Pods disappear ?  

---

## 0 answers

