kruise
kruise copied to clipboard
Are there plans to make the ordinal index for a statefulset available dynamically within a config file?
It would be good if there were some templating format so that the property could be set directly in the config file. E.g. (simplified):
apiVersion: apps.kruise.io/v1beta1
kind: StatefulSet
metadata:
name: zk
spec:
serviceName: zk-headless
replicas: 3
template:
metadata:
labels:
app: zk
spec:
containers:
- name: zk
imagePullPolicy: Always
image: zookeeper
resources:
env:
- name : ZOO_MY_ID
value: ${{ordinal}}
- name : ZOO_SERVERS
value: server.0=zk-0:2888:3888 server.1=zk-1:2888:3888 server.2=zk-2:2888:3888
- name : ZOO_TICK_TIME
value: "2000"
- name : ZOO_INIT_LIMIT
value: "10"
- name : ZOO_SYNC_LIMIT
value: "5"
What would you like to be added:
Why is this needed:
you can use the downward api populated env to get pod name which has suffix of ordinals
apiVersion: apps.kruise.io/v1beta1
kind: StatefulSet
metadata:
name: zk
spec:
serviceName: zk-headless
replicas: 3
template:
metadata:
labels:
app: zk
spec:
containers:
- name: zk
imagePullPolicy: Always
image: zookeeper
resources:
env:
- name : ZOO_MY_ID
valueFrom:
fieldRef:
fieldPath: metadata.name
- name : ZOO_SERVERS
value: server.0=zk-0:2888:3888 server.1=zk-1:2888:3888 server.2=zk-2:2888:3888
- name : ZOO_TICK_TIME
value: "2000"
- name : ZOO_INIT_LIMIT
value: "10"
- name : ZOO_SYNC_LIMIT
value: "5"
is there anyway/anyplans to get that ordinal directly at creation-time, instead at runtime? well,I want to set ordinal index to env, but not working.
@l-duan Different containers in a same pod have different environments, so you can not export the env from init container to another container.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.