Kubeflow Cheat Sheet
Run ML pipelines, hyperparameter tuning, and model serving on Kubernetes using Kubeflow Pipelines, Katib, and KServe components.
3 PagesAdvancedMar 15, 2026
Define a Kubeflow Pipeline
Compose Python components into a DAG using the Kubeflow Pipelines SDK v2.
python
from kfp import dsl, compiler@dsl.component(base_image="python:3.11", packages_to_install=["pandas"])def preprocess(input_path: str, output_path: dsl.Output[dsl.Dataset]): import pandas as pd df = pd.read_csv(input_path) df.dropna().to_csv(output_path.path, index=False)@dsl.component(base_image="python:3.11", packages_to_install=["scikit-learn"])def train(dataset: dsl.Input[dsl.Dataset], model: dsl.Output[dsl.Model]): import pandas as pd, joblib from sklearn.ensemble import RandomForestClassifier df = pd.read_csv(dataset.path) clf = RandomForestClassifier().fit(df.drop(columns=["label"]), df["label"]) joblib.dump(clf, model.path)@dsl.pipeline(name="train-pipeline")def pipeline(input_path: str = "gs://bucket/data.csv"): prep = preprocess(input_path=input_path) train(dataset=prep.outputs["output_path"])compiler.Compiler().compile(pipeline, "pipeline.yaml")
Submit a Pipeline Run
Upload and trigger a compiled pipeline against a Kubeflow Pipelines endpoint.
python
import kfpclient = kfp.Client(host="https://kubeflow.mycompany.com/pipeline")run = client.create_run_from_pipeline_package( pipeline_file="pipeline.yaml", arguments={"input_path": "gs://bucket/data.csv"}, experiment_name="fraud-model-training",)print(run.run_id)
Katib Hyperparameter Tuning
Define a Katib Experiment CRD to search hyperparameters across many training pods.
yaml
apiVersion: kubeflow.org/v1beta1kind: Experimentmetadata: name: rf-tuningspec: objective: type: maximize goal: 0.95 objectiveMetricName: accuracy algorithm: algorithmName: bayesianoptimization parameters: - name: n_estimators parameterType: int feasibleSpace: { min: "50", max: "500" } - name: max_depth parameterType: int feasibleSpace: { min: "2", max: "20" } trialTemplate: primaryContainerName: training-container trialParameters: - name: n_estimators reference: n_estimators - name: max_depth reference: max_depth
Deploy a Model with KServe
Create an InferenceService that serves a model from cloud storage with autoscaling.
yaml
apiVersion: serving.kserve.io/v1beta1kind: InferenceServicemetadata: name: fraud-modelspec: predictor: sklearn: storageUri: "gs://bucket/models/fraud-model/" minReplicas: 1 maxReplicas: 5
Kubeflow Components
The main subsystems and what each one is responsible for.
- Kubeflow Pipelines (KFP)- authors and orchestrates multi-step ML DAGs as Kubernetes workflows
- Katib- hyperparameter tuning and neural architecture search operator
- KServe- model serving with autoscaling, canary rollouts, and multi-framework support
- Notebooks- managed Jupyter environments running as Kubernetes pods
- Training Operators (TFJob/PyTorchJob)- CRDs for distributed training jobs
- Central Dashboard- unified web UI across all Kubeflow components
Pro Tip
Keep pipeline components small and single-purpose with explicit typed inputs/outputs — it makes the KFP cache reuse identical upstream steps across runs, which is where most of the iteration-speed win comes from.
Was this cheat sheet helpful?
Explore Topics
#Kubeflow#KubeflowCheatSheet#DataScience#Advanced#DefineAKubeflowPipeline#SubmitAPipelineRun#KatibHyperparameterTuning#DeployAModelWithKServe#MachineLearning#Kubernetes#DevOps#CheatSheet#SkillVeris
Advertisement
Sri Hayavadhana Info-Tech
Professional Web Designing Services
- Responsive Websites
- E-commerce Solutions
- SEO Friendly Design
- Fast & Secure
- Support & Maintenance