- Local scripts are convenient for prototyping but don’t provide retries, resource scheduling, isolated environments, or experiment orchestration.
- KFP turns Python functions into managed steps and delegates execution to Kubernetes, which runs containers on cluster nodes, allocates CPU/GPU, restarts failed workloads, and handles scaling.


- In KFP, components are the building blocks of a pipeline. You write Python functions and convert them into remote components with
@dsl.component. - Each component executes in its own container created by the KFP backend as Kubernetes resources (pods, jobs, etc.).
- To improve portability, put imports inside the component function so the component clearly declares its runtime dependencies.
- Each component runs inside a container image. Your local dev environment may differ from that image.
- The image determines the Python version and OS-level libraries available to the component.
- KFP’s
@dsl.componentsupports abase_imageparameter to specify the image (for example,python:3.10-slim). - You can also use
packages_to_installto pip-install dependencies at component startup.

Use
base_image and packages_to_install for rapid prototyping. For production or large-scale pipelines, build a custom image with your dependencies preinstalled to reduce cold-start times and improve reproducibility.
Tips for building custom images
- Start from an official base (e.g.,
python:3.10-slim) and install system libs first (apt packages) before Python packages. - Pin package versions in
requirements.txtand build image in CI to ensure reproducibility. - Push images to a registry accessible by your Kubernetes cluster (e.g., Docker Hub, GCR, ECR, or a private registry).
- Use multi-stage builds to reduce final image size and include only necessary runtime artifacts.
- Customizing the component image gives you control over the runtime environment. For prototypes, use
base_imagepluspackages_to_install. For production or large-scale scenarios, build and maintain custom images to reduce startup time, ensure dependency reproducibility, and simplify operations.