How kubernetes-retired/kube-batch works
kube-batch is a Kubernetes batch scheduler: it watches cluster and scheduling state, builds a scheduling session, evaluates jobs against resources and policies, then performs scheduling actions. The graph highlights allocation, backfill, preemption, reclamation, and policy plugins alongside the generated scheduling API clients. Some action/plugin wiring and cache watch setup are not shown in the excerpts, so those links are omitted or marked unverified.
Main entry points: session.go Scheduling session · scheduler.go Scheduling loop · server.go Server and election · cache Cluster cache
Components 20
Scheduler runtime
- CLI entry
cmd/kube-batch/main.go - Server and election
cmd/kube-batch/app/server.go - Scheduling loop
pkg/scheduler/scheduler.go
Scheduling state
- Cluster cache
pkg/scheduler/cache - Scheduling session
pkg/scheduler/framework/session.go - Job model
pkg/scheduler/api/job_info.go
Scheduling decisions
- Allocation
pkg/scheduler/actions/allocate/allocate.go - Backfill
pkg/scheduler/actions/backfill/backfill.go - Preemption
pkg/scheduler/actions/preempt/preempt.go - Reclamation
pkg/scheduler/actions/reclaim/reclaim.go - Fit predicates
pkg/scheduler/plugins/predicates/predicates.go - Gang scheduling
pkg/scheduler/plugins/gang/gang.go - Fair-share policy
pkg/scheduler/plugins/proportion/proportion.go - Node ordering
pkg/scheduler/plugins/nodeorder/nodeorder.go - Priority policy
pkg/scheduler/plugins/priority/priority.go
Scheduling API
- PodGroup and Queue
pkg/apis/scheduling/v1alpha1/types.go - Versioned clients
pkg/client/clientset/versioned/clientset.go - Scheduling informers
pkg/client/informers/externalversions/factory.go
Other components
- Batch workloads
- Kubernetes API
Connections 23
- Batch workloads → Kubernetes API: submit jobs
- CLI entry → Server and election: starts
cmd/kube-batch/main.go - Server and election → Scheduling loop: constructs and runs
cmd/kube-batch/app/server.go - Server and election → Kubernetes API: connects
cmd/kube-batch/app/server.go - Scheduling loop → Cluster cache: starts and syncs
pkg/scheduler/scheduler.go - Scheduling loop → Scheduling session: opens and closes
pkg/scheduler/scheduler.go - Scheduling loop → Allocation: executes action
- Scheduling loop → Backfill: executes action
- Scheduling loop → Preemption: executes action
- Scheduling loop → Reclamation: executes action
- Cluster cache → Kubernetes API: reads pods
pkg/scheduler/cache/event_handlers.go - Scheduling session → Cluster cache: snapshots state
pkg/scheduler/framework/session.go - Scheduling session → Job model: uses job model
pkg/scheduler/framework/session.go - Allocation → Scheduling session: updates placement
pkg/scheduler/actions/allocate/allocate.go - Preemption → Scheduling session: updates placement
pkg/scheduler/actions/preempt/preempt.go - Fit predicates → Scheduling session: evaluates candidates
- Gang scheduling → Scheduling session: checks group readiness
- Fair-share policy → Scheduling session: evaluates queue share
- Node ordering → Scheduling session: orders nodes
- Priority policy → Scheduling session: orders jobs
- Versioned clients → PodGroup and Queue: serializes resources
- Scheduling informers → Versioned clients: uses client
pkg/client/informers/externalversions/factory.go - PodGroup and Queue → Kubernetes API: represents resources