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.
- 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 stage | Subproject | What you get |
|---|---|---|
| Data preparation | Spark Operator | Spark applications as Kubernetes resources |
| Development | Notebooks / Workspaces | Jupyter, VS Code or RStudio in the cluster, next to data and GPUs |
| Training | Trainer | Distributed training and LLM fine-tuning as a TrainJob |
| Optimization | Katib | Hyperparameter search and AutoML as an Experiment |
| Model management | Kubeflow Hub | Model Registry (versions, artifacts, metadata) and Model Catalog |
| Orchestration | Pipelines (KFP) | Multi-step workflows defined in Python, with tracked artifacts |
| Serving | KServe | InferenceService for predictive and generative models |
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.
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.
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.
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: 1Trainer 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.
apiVersion: serving.kserve.io/v1beta1
kind: InferenceService
metadata:
name: ridge
spec:
predictor:
model:
modelFormat:
name: sklearn
storageUri: s3://models/ridge/v3KServe 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.
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.