Labels, Annotations and Environment Variables

A reference for all labels, annotations, and environment variables in LWS.

Labels

KeyDescriptionExampleApplies to
leaderworkerset.sigs.k8s.io/nameThe name of the LeaderWorkerSet object to which these resources belong.leaderworkerset-multi-templatePod, StatefulSet, Service
leaderworkerset.sigs.k8s.io/template-revision-hashHash used to track the controller revision that matches a LeaderWorkerSet object.5c5fcdfb44Pod, StatefulSet
leaderworkerset.sigs.k8s.io/group-indexThe group to which it belongs.0Pod, StatefulSet (only worker)
leaderworkerset.sigs.k8s.io/group-keyUnique key identifying the group.689ce1b5…b07Pod, StatefulSet (only worker)
leaderworkerset.sigs.k8s.io/worker-indexThe index or identity of the pod within the group.0Pod
leaderworkerset.sigs.k8s.io/subgroup-indexTracks which subgroup the pod is part of.0Pod (only if SubGroup is set)
leaderworkerset.sigs.k8s.io/subgroup-keyPods that are part of the same subgroup will have the same unique hash value.92904e74…801Pod (only if SubGroup is set)

Annotations

KeyDescriptionExampleApplies to
leaderworkerset.sigs.k8s.io/sizeThe total number of pods in each group.4Pod
leaderworkerset.sigs.k8s.io/replicasReplicas Number of leader-workers groups.3StatefulSet (only leader)
leaderworkerset.sigs.k8s.io/leader-nameThe name of the leader pod.leaderworkerset-multi-template-0Pod (only worker)
leaderworkerset.sigs.k8s.io/exclusive-topologySpecifies the topology for exclusive 1:1 scheduling.cloud.google.com/gke-nodepoolLeaderWorkerSet, Pod (only if exclusive-topology is used)
leaderworkerset.sigs.k8s.io/subdomainPolicyDetermines what type of domain will be injected.UniquePerReplicaPod (only if leader and subdomainPolicy set to UniquePerReplica)
leaderworkerset.sigs.k8s.io/subgroup-sizeThe number of pods per subgroup.2Pod (only if SubGroup is set)
leaderworkerset.sigs.k8s.io/subgroup-exclusive-topologySpecifies the topology for exclusive 1:1 scheduling within a subgroup.topologyKeyLeaderWorkerSet, Pod (only if SubGroup is set and subgroup-exclusive-topology is used)
leaderworkerset.sigs.k8s.io/leader-requests-tpusIndicates if the leader pod requests TPU.truePod (only if leader pod requests TPU)

Environment Variables

KeyDescriptionExampleApplies to
LWS_LEADER_ADDRESSThe address of the leader via the headless service.leaderworkerset-multi-template-0.leaderworkerset-multi-template.defaultPod
LWS_GROUP_SIZETracks the size of the LWS group.4Pod
LWS_WORKER_INDEXThe index or identity of the pod within the group.2Pod
TPU_WORKER_HOSTNAMESHostnames of TPU workers only in the same subgroup.test-sample-1-5.default,test-sample-1-6.default,test-sample-1-7.default,test-sample-1-8.defaultPod (only if TPU enabled)
TPU_WORKER_IDID of the TPU worker.0Pod (only if TPU enabled)
TPU_NAMEName of the TPU.test-sample-1Pod (only if TPU enabled)

If you want to use more environment variables, they are available in the labels or annotations but not listed in the Environment Variables section. We can obtain the index by using the Downward API to pass the Pod’s label as an environment variable to the container.

Feedback

Was this page helpful?