Kubeflow Trainer
Basic information
Section titled “Basic information”| Item | Value |
|---|---|
| Version | Kubeflow Trainer v2.2.0, JobSet v0.11.0 |
| Official docs | Kubeflow Trainer |
| Upstream source | applications/trainer/upstream |
| Dev overlay | overlays/dev/kubeflow/overlays/trainer/crds, overlays/dev/kubeflow/overlays/trainer/platform |
Concepts and characteristics
Section titled “Concepts and characteristics”Kubeflow Trainer is a training control plane that provides TrainJob and reusable runtime templates so that users do not have to author the full Pod layout of distributed training again and again. A user declares the framework, number of nodes, number of processes, image, command, resources, and dataset and model locations in a Profile namespace, and the Trainer controller combines the selected runtime with the user settings to create a JobSet in the same namespace. The JobSet controller expands it into Kubernetes Jobs and Pods and manages execution order, distributed topology, and success and failure state.
Trainer does not provide training code, datasets, accelerators, or a model registry by itself. Actual behavior is determined by the runtime, container image, Secrets, PVCs, and scheduling environment that the TrainJob references. The current manifest installs both general-purpose distributed runtimes and specific LLM fine-tuning runtimes.
Trainer is therefore best understood as the execution abstraction for training workloads, not the whole ML lifecycle.
Architecture components
Section titled “Architecture components”| Component | Role |
|---|---|
| Trainer controller | Validates and reconciles TrainJobs and runtimes, creates JobSets, and updates TrainJob status. |
| Trainer admission webhook | Applies defaults to TrainJobs and validates TrainJob, TrainingRuntime, and ClusterTrainingRuntime. |
| TrainingRuntime / ClusterTrainingRuntime | Defines framework-specific JobSet templates, distributed training policy, initializers, and container defaults. |
| JobSet controller | Expands a JobSet into multiple Kubernetes Jobs and Pods and manages dependency, network, success, and failure policies. |
| JobSet admission webhook | Defaults and validates JobSets and JobSet-managed Pods. |
| TrainJob workload | The JobSet, Jobs, Pods, and dynamic PVCs when needed, created in the user’s Profile namespace. |
Custom resources
Section titled “Custom resources”| CRD | API | Scope | Role |
|---|---|---|---|
trainjobs.trainer.kubeflow.org | trainer.kubeflow.org/v1alpha1 | namespace | Declares the runtime reference and the training image, command, number of nodes, number of processes, resources, and initializers. |
trainingruntimes.trainer.kubeflow.org | trainer.kubeflow.org/v1alpha1 | namespace | Namespace-local runtime template that only TrainJobs in the same namespace can reference. |
clustertrainingruntimes.trainer.kubeflow.org | trainer.kubeflow.org/v1alpha1 | cluster | Cluster runtime template shared across namespaces. |
jobsets.jobset.x-k8s.io | jobset.x-k8s.io/v1alpha2 | namespace | Represents multiple replicated Jobs and their execution relationship as a single workload. |
The default kind of TrainJob.spec.runtimeRef is ClusterTrainingRuntime. If a TrainJob references a TrainingRuntime, the runtime and the TrainJob must be in the same namespace. The trainer block can specify image, command, args, environment variables, numNodes, numProcPerNode, and per-node resources, and the initializer block can specify dataset and model storageUris, credential Secrets, and environment variables.
Installed ClusterTrainingRuntimes
Section titled “Installed ClusterTrainingRuntimes”| Name | Framework | Current runtime image or purpose |
|---|---|---|
torch-distributed | Torch | Distributed training based on pytorch/pytorch:2.10.0-cuda12.8-cudnn9-runtime |
jax-distributed | JAX | Distributed training based on nvcr.io/nvidia/jax:25.10-py3 |
xgboost-distributed | XGBoost | ghcr.io/kubeflow/trainer/xgboost-runtime:v2.2.0 |
deepspeed-distributed | DeepSpeed | OpenMPI launcher and nodes, ghcr.io/kubeflow/trainer/deepspeed-runtime:v2.2.0 |
mlx-distributed | MLX | OpenMPI launcher and nodes, ghcr.io/kubeflow/trainer/mlx-runtime:v2.2.0 |
torchtune-llama3.2-1b | torchtune | Fine-tuning on 2 GPUs after the Alpaca dataset and Llama 3.2 1B model initializers |
torchtune-llama3.2-3b | torchtune | Fine-tuning on 2 GPUs after the Alpaca dataset and Llama 3.2 3B model initializers |
torchtune-qwen2.5-1.5b | torchtune | Fine-tuning on 2 GPUs after the Alpaca dataset and Qwen 2.5 1.5B model initializers |
The three torchtune runtimes start the trainer Job only after both the dataset initializer and the model initializer complete. The initializer PVC shared by the three stages is created per TrainJob as a 20Gi ReadWriteOnce volume according to the JobSet volumeClaimPolicies. The default storageUri values in the manifest point to Hugging Face datasets and models, so in an air-gapped cluster mirrored images alone are not enough, and the TrainJob or runtime must be configured separately with internally reachable artifact locations and credentials.
Role in Kubeflow
Section titled “Role in Kubeflow”If Notebook and Pipeline provide development environments and workflows, Trainer runs single-node or multi-node training workloads on Kubernetes through a consistent API. The platform administrator puts the framework-specific Job and Pod topology details into runtimes, and users declare only the differences they need for training in the TrainJob.
- Profile namespace isolation: The TrainJob and the JobSet, Jobs, Pods, and PVCs it produces are placed in the namespace where the TrainJob was created.
- Distributed training abstraction: Rendezvous and replicated Job layouts for Torch, JAX, XGBoost, DeepSpeed, and MLX are reused as runtime templates.
- Initializer-stage configuration: When the runtime supports it, dataset and pre-trained model downloads are handled as separate Jobs with dependencies before trainer execution.
- Kubeflow RBAC integration: Trainer’s edit and view ClusterRoles aggregate into the Kubeflow aggregate roles, so Profile permissions can manage or view TrainJobs in the namespace.
- Katib integration: A Katib Experiment can use
TrainJobas its Trial template. Katib handles the parameter search, and Trainer handles the lifecycle of the generated training workload. - Boundary between execution and results: Trainer runs training workloads and manages their status, but it does not automatically register output models in Model Registry or automatically deploy them to KServe.
Kubeflow Trainer is the training-execution abstraction layer of this platform. It turns higher-level TrainJob declarations into concrete JobSet-based distributed workloads while keeping the complexity of framework-specific topology inside reusable runtimes. In this repository it is intentionally focused on that execution role: it launches and tracks training jobs well, but it does not pretend to solve data access, model registration, or serving rollout on its own.
Deployment structure
Section titled “Deployment structure”Overlay layout
Section titled “Overlay layout”Trainer applies CRDs and the platform as separate overlays.
overlays/dev/kubeflow/overlays/trainer/crds -> applications/trainer/upstream/base/crds -> TrainJob / TrainingRuntime / ClusterTrainingRuntime CRD
overlays/dev/kubeflow/overlays/trainer/platform -> applications/trainer/overlays -> upstream/overlays/kubeflow-platform -> Trainer manager + Trainer CRD + webhook + RBAC -> JobSet controller + JobSet CRD + webhook + RBAC -> 8개 ClusterTrainingRuntime -> Kubeflow aggregate roleThe platform bundle already includes the controllers, JobSet, runtimes, and roles. Therefore runtimes and roles are not added to the overlay again. In the final build, both controllers and all namespaced control-plane resources are placed in the kubeflow-system namespace.
Both controller Pods receive Istio sidecars because of the namespace label. Both Deployments carry the traffic.sidecar.istio.io/excludeInboundPorts: "9443" annotation so that the Kubernetes API server can reach the webhook backends directly. The Trainer Service exposes webhook 443 -> 9443, metrics 8443, and status server 10443, and the JobSet webhook Service exposes 443 -> 9443.
Apply order
Section titled “Apply order”- Server-side apply the
crdsoverlay and wait until thetrainjobs.trainer.kubeflow.orgCRD is Established. - Server-side apply the
platformoverlay. Even though this bundle includes the Trainer CRDs again, it is a separate apply, so it is not a duplicate resource within one build. - Wait until the
kubeflow-trainer-controller-managerandjobset-controller-managerDeployments are Available. - Wait until the
caBundleof the Trainer and JobSet webhook configurations is populated, then create TrainJobs.
Trainer and JobSet each use internal certificate management. The controllers fill the empty kubeflow-trainer-webhook-cert and jobset-webhook-server-cert Secrets and update the webhook configuration caBundle, so they do not depend on cert-manager Certificate resources. Unlike several other components in this repository, Trainer and JobSet therefore do not use cert-manager for webhook serving certificates. Rollout restarts, waiting for the webhook caBundle, and waiting for endpoint propagation are imperative operational steps and are not included in the kustomize resources.
Deployment view
Section titled “Deployment view”Resource Placement
Section titled “Resource Placement”| Namespace | Resource | Name | Role |
|---|---|---|---|
kubeflow-system | Deployment + Service | kubeflow-trainer-controller-manager | TrainJob reconcile, Trainer admission webhook, metrics and status endpoints |
kubeflow-system | Deployment + Service | jobset-controller-manager, jobset-webhook-service | JobSet reconcile and JobSet and Pod admission webhooks |
kubeflow-system | ConfigMap | kubeflow-trainer-config | Health, metrics, webhook, leader election, controller concurrency, and internal certificate settings |
kubeflow-system | ConfigMap | jobset-manager-config | JobSet leader election and internal certificate settings |
kubeflow-system | ConfigMap | kubeflow-trainer-public | Public information kubeflow_trainer_version=v2.2.0 that the SDK checks |
kubeflow-system | Secret | kubeflow-trainer-webhook-cert, jobset-webhook-server-cert | Webhook serving certificates managed by the controllers |
| cluster | CRD | Three Trainer CRDs, one JobSet CRD | Establishes the training API and JobSet API |
| cluster | webhook configuration | defaulter.trainer.kubeflow.org, validator.trainer.kubeflow.org | TrainJob defaulting and Trainer resource validation |
| cluster | webhook configuration | jobset-mutating-webhook-configuration, jobset-validating-webhook-configuration | Defaulting and validation of JobSets and their Pods |
| cluster | ClusterTrainingRuntime | Eight default runtimes | Provides framework-specific JobSet templates and initializers |
| cluster | ClusterRole + ClusterRoleBinding | Trainer / JobSet role set | Controller permissions, Kubeflow aggregate roles, cluster runtime read access for authenticated users |
| Profile namespace | TrainJob | Created dynamically per user | Training request and status API |
| Profile namespace | JobSet, Job, Pod, Service, PVC | Created dynamically per TrainJob | Actual initializer and distributed training workloads |
Diagram
Section titled “Diagram”PlantUML source:
Runtime flow
Section titled “Runtime flow”From TrainJob to training Pods
Section titled “From TrainJob to training Pods”- A user, Pipeline, or Katib creates a TrainJob in a Profile namespace.
- The Kubernetes API server checks the requester’s namespace permissions through Kubeflow aggregate RBAC and calls the Trainer mutating and validating webhooks.
- The Trainer controller resolves the TrainJob’s
runtimeRef. A ClusterTrainingRuntime is looked up at cluster scope, and a TrainingRuntime is looked up in the same namespace as the TrainJob. - The controller merges the TrainJob’s trainer, initializer, and runtime patches into the runtime template and creates a JobSet with the same name and namespace.
- The Kubernetes API server calls the JobSet admission webhooks, and the JobSet controller creates the replicated Jobs, Services, Pods, and the PVCs defined in the runtime.
- For runtimes with an initializer stage, the trainer Job starts after the dataset and model Jobs complete. General distributed runtimes start training Pods according to the runtime’s replicated Job topology.
- The JobSet controller aggregates Job and Pod state into the JobSet, and the Trainer controller reflects it into the TrainJob’s conditions and child Job status.
PlantUML source:
In the admission flow, the webhook configuration only provides the call rules and the backend location. Actual defaulting and validation are performed by the Kubernetes API server calling the controller Services in kubeflow-system, and the webhook configuration does not modify workloads directly.
Dependencies and interactions
Section titled “Dependencies and interactions”Prerequisites / downstream
Section titled “Prerequisites / downstream”- Prerequisite: The
kubeflow-systemnamespace and its Istio injection, PodSecurity, and NetworkPolicy baseline must exist first before the two controllers can be placed. - Prerequisite: The three Trainer CRDs must be Established before the platform bundle’s controllers and ClusterTrainingRuntimes can be applied reliably.
- Prerequisite: Actual TrainJob execution requires a registry to pull runtime images from, the requested CPU and GPU, a scheduler, a storage class, dataset and model endpoints, and namespace-local Secrets.
- Prerequisite: The target namespace must already exist with appropriate Kubeflow RBAC.
- Downstream: When Katib uses TrainJob as a Trial workload, the Trainer CRDs, Trainer controller, and JobSet controller must be Ready.
- Downstream: When a Pipeline uses a step that creates or waits for a TrainJob, it depends on the same runtimes and Profile namespace RBAC.
- Downstream: Model Registry and KServe are not automatically wired after training completion.
Runtime interactions
Section titled “Runtime interactions”- The Kubernetes API server calls
kubeflow-trainer-controller-manager.kubeflow-system.svc:443for Trainer resource admission. - The Kubernetes API server calls
jobset-webhook-service.kubeflow-system.svc:443for admission of JobSets and JobSet-managed Pods. - The Trainer controller watches TrainJobs and runtimes at cluster scope and creates and manages JobSets in the TrainJob namespace.
- The JobSet controller creates Jobs, Pods, and Services in the JobSet namespace and aggregates their state.
kubeflow-trainer-editandkubeflow-trainer-viewaggregate into Kubeflow’skubeflow-editandkubeflow-viewaggregate roles respectively. All authenticated users can get, list, and watch ClusterTrainingRuntimes through the default ClusterRoleBinding.- There is no Dashboard ingress or Istio VirtualService between the control plane and training workloads. TrainJob creation and lookup go through the Kubernetes API and RBAC.
- Trainer does not synchronize Secrets, Notebook volumes, or artifact storage automatically. If a training job needs access to data, models, credentials, or GPUs, that must be expressed through the chosen runtime and
TrainJobspec.
Key resources
Section titled “Key resources”TrainJob: The user API that holds the runtime selection and per-training overrides.runtimeRefis required, and suspend and active deadline are supported.TrainingRuntime: A template exposed only to a specific Profile namespace. Use it when a namespace needs its own image, policy, or storage contract.ClusterTrainingRuntime: A cluster-wide shared framework template. The current manifest installs eight runtimes.JobSet: The execution plan created by Trainer. It turns replicated Job dependencies, network, and success policy into actual Job and Pod lifecycles.kubeflow-trainer-config: Provides controller concurrency, secure metrics, webhook port, leader election, certificate, and status server settings.- Webhook certificate Secrets: The Trainer and JobSet controllers manage the serving certificate and webhook
caBundlelifecycle. - Kubeflow aggregate roles: Add TrainJob and TrainingRuntime permissions to Profile edit and view permissions. The edit role can create, update, and delete TrainJobs and read Pod logs and events, but it does not modify ClusterTrainingRuntimes.
Operational boundary and verification criteria
Section titled “Operational boundary and verification criteria”A Ready Trainer control plane and a runnable TrainJob are separate things. Runtime image mirrors, internal endpoints for datasets and models, the GPU device plugin, node capacity, storage classes, quotas, and namespace Secrets must be prepared separately by the platform operator. In particular, the Hugging Face URIs and public registry images in the current torchtune runtimes are not reachable as is in an air-gapped environment, so a runtime rewritten to an internal artifact contract or a TrainJob override is required.
After deployment, verify the following lifecycle on the actual cluster.
- The three Trainer CRDs and the JobSet CRD are Established.
- Both controller Deployments are Available and Ready together with their Istio sidecars.
- The
caBundleof the Trainer and JobSet webhook configurations is not empty and admission calls succeed. - A user with Profile permissions can view ClusterTrainingRuntimes and create a TrainJob in their own namespace.
- The TrainJob is converted into a JobSet in the same namespace, and the JobSet creates Jobs and Pods.
- Image pull, Secret references, PVC provisioning, and CPU and GPU scheduling for the selected runtime succeed.
- Success, failure, suspend, and deadline states are reflected from the JobSet into the TrainJob conditions.
- When the TrainJob and JobSet are deleted, child Jobs, Pods, and PVCs created dynamically by the runtime are cleaned up according to the intended lifecycle policy.
TrainJobadmission works and defaulting is applied.- Initializer Jobs run when the runtime expects them, and trainer Jobs and Pods start with the intended node and process topology.
- The internally managed webhook Secrets and
caBundlefields stay valid across restarts.
References
Section titled “References”- Overlay:
overlays/dev/kubeflow/overlays/trainer/crds,overlays/dev/kubeflow/overlays/trainer/platform - Namespace baseline: Namespace
- Profile namespace and RBAC: User Profile
- HPO integration: Katib
- Pipeline integration: Kubeflow Pipelines
- Queue quota and job admission: Kueue and GPU Job Admission