Dual Pod Templates
LeaderWorkerSet supports defining distinct specifications for leader and worker pods within a replica.
Leader and Worker Templates
An LWS replica consists of one leader pod and N - 1 worker pods (where N is defined by .spec.leaderWorkerTemplate.size).
You can configure pod specifications using two template fields:
workerTemplate(required): Defines the pod template for worker pods. IfleaderTemplateis not specified,workerTemplateapplies to the leader pod as well.leaderTemplate(optional): Defines a distinct pod template exclusively for the leader pod.
apiVersion: leaderworkerset.x-k8s.io/v1
kind: LeaderWorkerSet
metadata:
name: leaderworkerset-sample
spec:
replicas: 3
leaderWorkerTemplate:
size: 4
leaderTemplate:
spec:
containers:
- name: leader
image: leader-coordinator:latest
resources:
requests:
cpu: "2"
memory: 4Gi
workerTemplate:
spec:
containers:
- name: worker
image: worker-engine:latest
resources:
limits:
nvidia.com/gpu: "8"
Common Use Cases
Heterogeneous Hardware: The leader pod can run as a coordinator, HTTP frontend, or driver on standard CPU nodes, while the worker pods run distributed model parallel computation on specialized GPU or TPU accelerator nodes.
Different Container Images or Configurations: The leader pod can run specialized tooling, telemetry sidecars, or API server processes that are not needed on worker pods.
Homogeneous Deployments: When leader and worker pods share the same container configuration, omit
leaderTemplateand specify onlyworkerTemplate. LWS will applyworkerTemplateto all pods in the replica.
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.