Education › OSS Deep Dives › Stage 2: MLOps platforms

Kubeflow: the ML platform on Kubernetes

The subprojects — Pipelines, Trainer, Katib, KServe, Notebooks, Model Registry — and how they fit the ML lifecycle.

Intermediate ~35 min read Module 3 of 10

Kubeflow is not one program. The kubeflow/kubeflow repository now holds little more than a README, because Kubeflow is a family of subprojects, each with its own repository, that together cover the ML lifecycle on Kubernetes: notebooks, pipelines, distributed training, hyperparameter search, a model registry, and serving through KServe. This lesson maps the subprojects to the lifecycle, shows the resources and Python APIs you actually use, and explains how to install only the parts you need.

After this module you can
  • Map each Kubeflow subproject to a stage of the ML lifecycle
  • Write and compile a Kubeflow Pipelines v2 pipeline in Python
  • Launch distributed training as a TrainJob, from YAML or the Kubeflow SDK
  • Explain what Katib, Kubeflow Hub and KServe add after training
  • Decide between the full platform install and individual components

A platform made of subprojects

Kubeflow describes itself as the cloud-native AI platform: modular open-source projects that form a Kubernetes-native stack for data and AI work. Each subproject is maintained by a working group and released on its own schedule. You can adopt one, such as only Pipelines, without the rest.

Lifecycle stageSubprojectWhat you get
Data preparationSpark OperatorSpark applications as Kubernetes resources
DevelopmentNotebooks / WorkspacesJupyter, VS Code or RStudio in the cluster, next to data and GPUs
TrainingTrainerDistributed training and LLM fine-tuning as a TrainJob
OptimizationKatibHyperparameter search and AutoML as an Experiment
Model managementKubeflow HubModel Registry (versions, artifacts, metadata) and Model Catalog
OrchestrationPipelines (KFP)Multi-step workflows defined in Python, with tracked artifacts
ServingKServeInferenceService for predictive and generative models
ORCHESTRATED BY KUBEFLOW PIPELINESsubmittuneregister bestdeploy versionWorkspacesnotebooks, IDEsTrainerTrainJobKatibExperiment, trialsKubeflow HubModel RegistryKServeInferenceService
Each Kubeflow subproject owns one stage of the ML lifecycle, and Pipelines strings the stages together into a repeatable, tracked run.

Names have shifted recently, so expect older blog posts to differ. The Model Registry is now part of Kubeflow Hub. The Training Operator v1 (PyTorchJob, TFJob) was replaced by Kubeflow Trainer v2 and its single TrainJob resource. Workspaces (beta) is the next generation of Notebooks. KServe started inside Kubeflow, now lives in its own kserve/kserve repository, and the Kubeflow manifests still ship it. On top sits the Kubeflow SDK, one Python package that drives Trainer, Katib and Spark without writing YAML.

Kubeflow Pipelines: workflows as Python

A pipeline is a graph of components, and each component runs in its own container. With the KFP v2 SDK you write components as decorated Python functions, wire them together in a pipeline function, and compile the result to a YAML intermediate representation that the KFP backend runs. Outputs that are passed between steps (datasets, models, metrics) are stored as artifacts, so every run records exactly what went in and what came out.

Two-step pipeline: train, then evaluate
python
from kfp import compiler, dsl
from kfp.dsl import Input, Metrics, Model, Output


@dsl.component(base_image="python:3.12", packages_to_install=["scikit-learn"])
def train(alpha: float, model: Output[Model]):
    import pickle
    from sklearn.datasets import load_diabetes
    from sklearn.linear_model import Ridge
    X, y = load_diabetes(return_X_y=True)
    with open(model.path, "wb") as f:
        pickle.dump(Ridge(alpha=alpha).fit(X, y), f)


@dsl.component(base_image="python:3.12", packages_to_install=["scikit-learn"])
def evaluate(model: Input[Model], metrics: Output[Metrics]):
    import pickle
    from sklearn.datasets import load_diabetes
    X, y = load_diabetes(return_X_y=True)
    with open(model.path, "rb") as f:
        metrics.log_metric("r2", pickle.load(f).score(X, y))


@dsl.pipeline(name="ridge-train-eval")
def pipeline(alpha: float = 1.0):
    trained = train(alpha=alpha)
    evaluate(model=trained.outputs["model"])


compiler.Compiler().compile(pipeline, "pipeline.yaml")

Upload pipeline.yaml in the Pipelines UI or submit it with kfp.Client().create_run_from_pipeline_package(...). Steps whose inputs have not changed can be served from the cache, which saves a lot of time while you iterate on the last step. If your team works in notebooks, Kale compiles a tagged notebook into the same KFP v2 pipeline without writing the decorators by hand.

Tip

Keep components small and pure: inputs in, artifacts out, no hidden reads from a shared disk. That is what makes caching, retries and lineage trustworthy.

Trainer: distributed training as one resource

Kubeflow Trainer separates two concerns. Platform engineers publish runtimes (ClusterTrainingRuntime or namespaced TrainingRuntime) that encode how to launch a framework: the image, torchrun or MPI setup, and the JobSet that creates the pods. The repository ships runtimes for PyTorch, DeepSpeed, JAX, MLX, XGBoost and torchtune. Data scientists then write a short TrainJob that references a runtime and says how many nodes and what to run.

Three-node PyTorch job on the built-in torch-distributed runtime
yaml
apiVersion: trainer.kubeflow.org/v1alpha1
kind: TrainJob
metadata:
  name: fine-tune-demo
spec:
  runtimeRef:
    apiGroup: trainer.kubeflow.org
    kind: ClusterTrainingRuntime
    name: torch-distributed
  trainer:
    numNodes: 3
    image: ghcr.io/example/trainer:0.4.0
    command: ["torchrun", "train.py"]
    resourcesPerNode:
      limits:
        nvidia.com/gpu: 1

Trainer injects the rendezvous settings (master address, node rank, number of nodes) so torchrun finds its peers. The same job can be submitted from Python with the SDK's TrainerClient().train(...), passing a function plus num_nodes and resources_per_node, which is how most notebook users will meet it. For GPU fairness across teams, pair Trainer with Kueue, which queues TrainJobs until quota is free.

After training: Katib, Hub and KServe

Katib runs an Experiment: an objective metric to maximise or minimise, a search algorithm (random, grid, Bayesian optimisation, Hyperband and others), a search space of parameters, and a trial template that is launched once per parameter set. It stops early when a goal is reached or the trial budget is spent. The Kubeflow SDK exposes this as OptimizerClient().optimize(...) over the same template you used for training.

Kubeflow Hub holds the Model Registry: registered models, their versions, where the artifacts live, and metadata such as metrics and the training run that produced them. It is the hand-off point between "we trained something good" and "this version is what production serves". The Model Catalog alongside it is a read-only view of curated external models you can browse before registering one.

KServe: serve a registered model version
yaml
apiVersion: serving.kserve.io/v1beta1
kind: InferenceService
metadata:
  name: ridge
spec:
  predictor:
    model:
      modelFormat:
        name: sklearn
      storageUri: s3://models/ridge/v3

KServe turns that into a scalable endpoint with a standard inference protocol, and for LLMs it can run vLLM as the runtime. Scale-to-zero relies on Knative, which is one reason a full Kubeflow install pulls in Knative and Istio.

Installing: full platform or just the parts

The Kubeflow manifests repository (the community distribution) installs everything with Kustomize: the applications above plus common services, namely Istio for networking and auth, Knative for KServe, cert-manager, Dex and oauth2-proxy for login, and the Central Dashboard that stitches the UIs together with per-user profiles (namespaces). The documented one-liner retries until all CRDs are established.

Full platform from a checkout of the manifests repo (needs a large cluster)
bash
while ! kustomize build example | kubectl apply --server-side --force-conflicts -f -; do
  echo "Retrying to apply resources"
  sleep 20
done
  • The full platform needs real capacity; the README suggests excluding components to fit into 4 to 8 GB of memory on a laptop.
  • If you only need pipelines, install Kubeflow Pipelines standalone; if you only need distributed training, install Trainer alone. Each subproject documents a standalone install.
  • Managed distributions from cloud and platform vendors package the same components with their own auth and storage; pick one if you do not want to run Istio yourself.
  • Upgrades are per component: read each subproject's release notes, because CRD versions move independently.
Hands-on practice

Run a pipeline and a TrainJob on a laptop

  1. Create a kind cluster with at least 8 GB of memory available to Docker.
  2. Install Kubeflow Pipelines standalone by following the KFP docs for your version, then port-forward the ml-pipeline-ui service and open the UI.
  3. Run pip install kfp, save the pipeline from this lesson as pipeline.py, run it, and upload the generated pipeline.yaml.
  4. Start a run with alpha=1.0, then another with alpha=10.0, and compare the logged r2 metrics in the UI.
  5. Re-run with the same parameters and confirm the train step is served from the cache.
  6. Install Kubeflow Trainer standalone, apply a TrainJob that uses torch-distributed with numNodes: 2 and a CPU-only script, and watch the pods with kubectl get pods -w.
  7. Delete the cluster when you are done with kind delete cluster.
Cheat sheet

Kubeflow: the ML platform on Kubernetes — at a glance

Main things to focus on

  • Kubeflow is a set of independently released subprojects; adopt only what you need.
  • Pipelines: components are containers, artifacts are tracked, steps are cached.
  • Trainer v2: platform publishes runtimes, users submit a short TrainJob.
  • Katib searches hyperparameters; Hub records which model version is which; KServe serves it.
  • Older docs say Training Operator, PyTorchJob and Model Registry: the current names are Trainer, TrainJob and Kubeflow Hub.
  • The full install brings Istio, Knative, Dex and cert-manager: budget for them.

KFP v2 SDK

@dsl.component(base_image=..., packages_to_install=[...])A Python function that runs as its own container step
@dsl.pipeline(name=...)Wire components together; return values become task outputs
Output[Model] / Input[Dataset] / Output[Metrics]Typed artifacts passed between steps
compiler.Compiler().compile(pipeline, "p.yaml")Compile to the IR YAML the backend runs
task.set_caching_options(False)Force a step to re-run every time

Trainer

kind: TrainJob runtimeRef: {name: torch-distributed}Training job on a published runtime
trainer.numNodes / trainer.resourcesPerNodeScale out and request GPUs per node
kubectl get clustertrainingruntimesRuntimes the platform offers
TrainerClient().train(**template)Submit from Python with the Kubeflow SDK
TrainerClient().get_job_logs(name=job_id)Fetch training logs from Python

Katib and KServe

kind: Experiment objective / algorithm / parametersHyperparameter search definition
maxTrialCount / parallelTrialCountSearch budget and concurrency
kind: InferenceService predictor.model.storageUriServe a model from object storage
kubectl get inferenceserviceEndpoint URL and READY state

Install

kustomize build example | kubectl apply --server-side -f -Whole platform from the manifests repo (retry until CRDs settle)
kubectl port-forward svc/istio-ingressgateway -n istio-system 8080:80Reach the Central Dashboard locally
applications/ and common/Manifests layout: Kubeflow components vs shared services

Common pitfalls

  • Installing the whole platform on a small cluster when you only needed Pipelines.
  • Following a tutorial for PyTorchJob or the v1 SDK and wondering why the CRDs do not exist.
  • Components that read and write a shared volume instead of artifacts, which breaks caching and lineage.
  • Letting several teams submit GPU TrainJobs without a queue such as Kueue, so jobs half-start and deadlock.
  • Treating the model registry as optional and losing track of which artifact production serves.
Quiz

Check your understanding

5 questions · 4 to pass · answers are explained as you go. Your best score is saved on this device only.

Progress and quiz scores are saved in this browser only. Back up or restore on the hub.

Was this lesson useful? Tell me what to improve →