To use this feature, you (or a cluster administrator) will need to enable the CompositePodGroup feature gate for all relevant components in your cluster.
See Enable Or Disable Feature Gates for more information.
A CompositePodGroup is a runtime object that represents a non-leaf node in a multi-level workload
hierarchy. While the Workload API defines static scheduling
policy templates, CompositePodGroup and PodGroup objects are the runtime counterparts that
carry policies and hierarchy references for a specific workload instance.
The CompositePodGroup API resource is part of the scheduling.k8s.io/v1beta1
API group. Your cluster must have that API
group enabled, as well as the CompositePodGroup
feature gate,
before you can use this API.
A CompositePodGroup represents a grouping of child groups (which can be CompositePodGroup or
PodGroup objects). It carries scheduling policies, disruption modes, priority
settings, and optional topology constraints that apply collectively across its child groups.
A CompositePodGroup consists of a spec that defines the desired scheduling behavior
for its child groups, and a status subresource.
Each CompositePodGroup carries a scheduling policy
(basic or gang) in spec.schedulingPolicy. When a workload controller creates a
CompositePodGroup, this policy is copied from the Workload's CompositePodGroupTemplate
at creation time.
For a gang policy on a CompositePodGroup, the minGroupCount field specifies the
minimum number of child groups that must be schedulable simultaneously:
spec:
schedulingPolicy:
gang:
minGroupCount: 2
While the policy type itself (basic or gang) cannot be changed after creation, minGroupCount
is mutable to support workload scaling. Updates to minGroupCount only apply to future scheduling
cycles and do not affect already-scheduled Pods.
Non-root CompositePodGroup resources specify their parent group using
spec.parentCompositePodGroupName. Root CompositePodGroup objects leave this field unset.
spec:
parentCompositePodGroupName: root-group-0
The required spec.workloadRef field links the CompositePodGroup back to the
CompositePodGroupTemplate in the Workload object it was derived from.
spec:
workloadRef:
workloadName: hierarchical-workload
templateName: replica-group
The scheduler updates status.conditions on each CompositePodGroup to report whether the
scheduling requirements for the subtree under that CompositePodGroup have been satisfied. The
primary condition is CompositePodGroupInitiallyScheduled, which is True when all required child
groups have been placed and False when scheduling fails.
CompositePodGroupInitiallyScheduled condition reflects the initial scheduling decision only.
The scheduler does not update it if Pods or child groups later fail, are deleted, or are evicted.See the CompositePodGroup conditions section for the full list of conditions and reasons.
Workload controllers create CompositePodGroup objects automatically from Workload
templates at runtime.
The following manifest creates a root CompositePodGroup with a gang scheduling policy
that requires at least 2 child groups to be schedulable simultaneously:
apiVersion: scheduling.k8s.io/v1beta1
kind: CompositePodGroup
metadata:
name: root-group-0
namespace: default
spec:
workloadRef:
workloadName: hierarchical-workload
templateName: root
schedulingPolicy:
gang:
minGroupCount: 2
You can inspect CompositePodGroup resources in your cluster:
kubectl get compositepodgroups
To view details for a specific composite group:
kubectl describe compositepodgroup root-group-0
The relationship between controllers, Workloads, CompositePodGroups, PodGroups, and Pods follows this pattern:
Workload defining a tree of
CompositePodGroupTemplates and leaf PodGroupTemplates.CompositePodGroup,
descendant CompositePodGroup objects, and leaf PodGroup objects in a top-down manner.Pods that reference their leaf PodGroup via
spec.schedulingGroup.podGroupName.The following example illustrates a complete manifest hierarchy for a two-level workload:
apiVersion: scheduling.k8s.io/v1beta1
kind: Workload
metadata:
name: hierarchical-workload
namespace: default
spec:
compositePodGroupTemplates:
- name: root
schedulingPolicy:
gang:
minGroupCount: 2
podGroupTemplates:
- name: workers-a
schedulingPolicy:
gang:
minCount: 4
- name: workers-b
schedulingPolicy:
gang:
minCount: 4
---
apiVersion: scheduling.k8s.io/v1beta1
kind: CompositePodGroup
metadata:
name: root-group-0
namespace: default
spec:
workloadRef:
workloadName: hierarchical-workload
templateName: root
schedulingPolicy:
gang:
minGroupCount: 2
---
apiVersion: scheduling.k8s.io/v1beta1
kind: PodGroup
metadata:
name: workers-a-0
namespace: default
spec:
parentCompositePodGroupName: root-group-0
workloadRef:
workloadName: hierarchical-workload
templateName: workers-a
schedulingPolicy:
gang:
minCount: 4
---
apiVersion: scheduling.k8s.io/v1beta1
kind: PodGroup
metadata:
name: workers-b-0
namespace: default
spec:
parentCompositePodGroupName: root-group-0
workloadRef:
workloadName: hierarchical-workload
templateName: workers-b
schedulingPolicy:
gang:
minCount: 4
---
apiVersion: v1
kind: Pod
metadata:
name: worker-a-0
namespace: default
spec:
schedulingGroup:
podGroupName: workers-a-0
containers:
- name: worker
image: registry.k8s.io/pause:3.9
The Workload acts as a long-lived policy template, while CompositePodGroup and
PodGroup resources handle per-instance runtime scheduling state.
CompositePodGroup hierarchies.