0

Currently when I apply stateful set then pods are getting created with ab-app-0, ab-app-1 , ab-app-2

But I want pods like ab-app-1000, ab-app-1001

1 Answers1

1

The Kubernetes documentation on StatefulSet says the following about ordinal index:

For a StatefulSet with N replicas, each Pod in the StatefulSet will be assigned an integer ordinal, from 0 up through N-1, that is unique over the Set.

So there looks to be no way of customising this. But if your concern is that you need to pass this unique ID to a service, you could do the following in the config file, as proposed in this open github issue:

        env:
        - name: ZOO_MY_ID
          valueFrom:
            fieldRef:
              fieldPath: metadata.annotations['spec.pod.beta.kubernetes.io/statefulset-index']
viggnah
  • 1,709
  • 1
  • 3
  • 12
  • I believe this is no longer true. Kubernetes now supports customizing the start index, and the only available annotation for StatefulSet-driven pods (per [documentation](https://kubernetes.io/docs/reference/labels-annotations-taints/#labels-annotations-and-taints-used-on-api-objects)) is the resulting pod name. – Tomer Gabel Jun 21 '23 at 09:06