# Can I get the number of current replicas from within statefulset pod with code?

**URL:** <https://discuss.kubernetes.io/t/can-i-get-the-number-of-current-replicas-from-within-statefulset-pod-with-code/11921>\
**Category:** General Discussions\
**Created:** [July 18, 2020, 8:53pm UTC](https://discuss.kubernetes.io/t/can-i-get-the-number-of-current-replicas-from-within-statefulset-pod-with-code/11921 "2020-07-18T20:53:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vbodurov](https://avatars.discourse-cdn.com/v4/letter/v/f04885/32.png) [@vbodurov](https://discuss.kubernetes.io/u/vbodurov)\
**Post date:** [July 18, 2020, 8:53pm UTC](https://discuss.kubernetes.io/t/can-i-get-the-number-of-current-replicas-from-within-statefulset-pod-with-code/11921/1 "2020-07-18T20:53:26Z")

</div>

Can I get the number of current replicas from within statefulset pod with code?

I know I can create environment variable during deployment but what if it gets re-scaled? Is there a way to know?

---

<div class="post-metadata">

**Author:** ![Bobses](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/bobses/32/250_2.png) [@Bobses](https://discuss.kubernetes.io/u/Bobses)\
**Post date:** [July 19, 2020, 5:34pm UTC](https://discuss.kubernetes.io/t/can-i-get-the-number-of-current-replicas-from-within-statefulset-pod-with-code/11921/2 "2020-07-19T17:34:16Z")

</div>

Use jsonPath. For example, the below line allows you to get the name of statefulset, the namespace and the current replicas for each one:

`kubectl get statefulset -A -o=custom-columns=NAME:.metadata.name,NAMESPACE:.metadata.namespace,CurrentReplicas:.status.currentReplicas`
