I created a StatefulSet and I want to pass to each of its pods the number of pods in this StatefulSet through an environment variable named REPLICASIZE. Is this possible? My yaml looks as:
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: php-app-4-rcweb
namespace: kube-system
labels:
app: mypod
spec:
replicas: 3
selector:
matchLabels:
app: mypod
template:
metadata:
labels:
app: mypod
spec:
containers:
- name: php-apache
image: my-registry.local:5000/my-image:0.0.1 # Or your custom image
env:
- name: TZ
...
- name: REPLICASIZE
value: ................
Asking for help? Comment out what you need so we can get more information to help you!
Cluster information:
Kubernetes version:
$ k3s -version
k3s version v1.33.3+k3s1 (236cbf25)
go version go1.24.4
Cloud being used: bare metal
Installation method:
curl -sfL https://get.k3s.io | sh -s -- --cluster-cidr=142.200.0.0/16 --service-cidr=142.201.0.0/16
Host OS: Ubuntu Linux 24
CNI and version: default
CRI and version: default