Skip to content

Kubeflow Trainer

Interactive Diagram

새 탭 ↗
ItemValue
VersionKubeflow Trainer v2.2.0, JobSet v0.11.0
Official docsKubeflow Trainer
Upstream sourceapplications/trainer/upstream
Dev overlayoverlays/dev/kubeflow/overlays/trainer/crds, overlays/dev/kubeflow/overlays/trainer/platform

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.

ComponentRole
Trainer controllerValidates and reconciles TrainJobs and runtimes, creates JobSets, and updates TrainJob status.
Trainer admission webhookApplies defaults to TrainJobs and validates TrainJob, TrainingRuntime, and ClusterTrainingRuntime.
TrainingRuntime / ClusterTrainingRuntimeDefines framework-specific JobSet templates, distributed training policy, initializers, and container defaults.
JobSet controllerExpands a JobSet into multiple Kubernetes Jobs and Pods and manages dependency, network, success, and failure policies.
JobSet admission webhookDefaults and validates JobSets and JobSet-managed Pods.
TrainJob workloadThe JobSet, Jobs, Pods, and dynamic PVCs when needed, created in the user’s Profile namespace.
CRDAPIScopeRole
trainjobs.trainer.kubeflow.orgtrainer.kubeflow.org/v1alpha1namespaceDeclares the runtime reference and the training image, command, number of nodes, number of processes, resources, and initializers.
trainingruntimes.trainer.kubeflow.orgtrainer.kubeflow.org/v1alpha1namespaceNamespace-local runtime template that only TrainJobs in the same namespace can reference.
clustertrainingruntimes.trainer.kubeflow.orgtrainer.kubeflow.org/v1alpha1clusterCluster runtime template shared across namespaces.
jobsets.jobset.x-k8s.iojobset.x-k8s.io/v1alpha2namespaceRepresents 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.

NameFrameworkCurrent runtime image or purpose
torch-distributedTorchDistributed training based on pytorch/pytorch:2.10.0-cuda12.8-cudnn9-runtime
jax-distributedJAXDistributed training based on nvcr.io/nvidia/jax:25.10-py3
xgboost-distributedXGBoostghcr.io/kubeflow/trainer/xgboost-runtime:v2.2.0
deepspeed-distributedDeepSpeedOpenMPI launcher and nodes, ghcr.io/kubeflow/trainer/deepspeed-runtime:v2.2.0
mlx-distributedMLXOpenMPI launcher and nodes, ghcr.io/kubeflow/trainer/mlx-runtime:v2.2.0
torchtune-llama3.2-1btorchtuneFine-tuning on 2 GPUs after the Alpaca dataset and Llama 3.2 1B model initializers
torchtune-llama3.2-3btorchtuneFine-tuning on 2 GPUs after the Alpaca dataset and Llama 3.2 3B model initializers
torchtune-qwen2.5-1.5btorchtuneFine-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.

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 TrainJob as 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.

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 role

The 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.

  1. Server-side apply the crds overlay and wait until the trainjobs.trainer.kubeflow.org CRD is Established.
  2. Server-side apply the platform overlay. Even though this bundle includes the Trainer CRDs again, it is a separate apply, so it is not a duplicate resource within one build.
  3. Wait until the kubeflow-trainer-controller-manager and jobset-controller-manager Deployments are Available.
  4. Wait until the caBundle of 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.

NamespaceResourceNameRole
kubeflow-systemDeployment + Servicekubeflow-trainer-controller-managerTrainJob reconcile, Trainer admission webhook, metrics and status endpoints
kubeflow-systemDeployment + Servicejobset-controller-manager, jobset-webhook-serviceJobSet reconcile and JobSet and Pod admission webhooks
kubeflow-systemConfigMapkubeflow-trainer-configHealth, metrics, webhook, leader election, controller concurrency, and internal certificate settings
kubeflow-systemConfigMapjobset-manager-configJobSet leader election and internal certificate settings
kubeflow-systemConfigMapkubeflow-trainer-publicPublic information kubeflow_trainer_version=v2.2.0 that the SDK checks
kubeflow-systemSecretkubeflow-trainer-webhook-cert, jobset-webhook-server-certWebhook serving certificates managed by the controllers
clusterCRDThree Trainer CRDs, one JobSet CRDEstablishes the training API and JobSet API
clusterwebhook configurationdefaulter.trainer.kubeflow.org, validator.trainer.kubeflow.orgTrainJob defaulting and Trainer resource validation
clusterwebhook configurationjobset-mutating-webhook-configuration, jobset-validating-webhook-configurationDefaulting and validation of JobSets and their Pods
clusterClusterTrainingRuntimeEight default runtimesProvides framework-specific JobSet templates and initializers
clusterClusterRole + ClusterRoleBindingTrainer / JobSet role setController permissions, Kubeflow aggregate roles, cluster runtime read access for authenticated users
Profile namespaceTrainJobCreated dynamically per userTraining request and status API
Profile namespaceJobSet, Job, Pod, Service, PVCCreated dynamically per TrainJobActual initializer and distributed training workloads

PlantUML source:

PlantUML Diagram
  1. A user, Pipeline, or Katib creates a TrainJob in a Profile namespace.
  2. The Kubernetes API server checks the requester’s namespace permissions through Kubeflow aggregate RBAC and calls the Trainer mutating and validating webhooks.
  3. 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.
  4. 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.
  5. 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.
  6. 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.
  7. 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:

PlantUML Diagram

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.

  • Prerequisite: The kubeflow-system namespace 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.
  • The Kubernetes API server calls kubeflow-trainer-controller-manager.kubeflow-system.svc:443 for Trainer resource admission.
  • The Kubernetes API server calls jobset-webhook-service.kubeflow-system.svc:443 for 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-edit and kubeflow-trainer-view aggregate into Kubeflow’s kubeflow-edit and kubeflow-view aggregate 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 TrainJob spec.
  • TrainJob: The user API that holds the runtime selection and per-training overrides. runtimeRef is 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 caBundle lifecycle.
  • 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 caBundle of 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.
  • TrainJob admission 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 caBundle fields stay valid across restarts.