{"id":9866,"library":"kfp-kubernetes","title":"KFP Kubernetes Platform Configuration","description":"kfp-kubernetes is a Python library providing Kubernetes platform configuration utilities and generated protobufs for Kubeflow Pipelines (KFP). It enables users to customize Kubernetes resources like volumes, secrets, node selectors, and tolerations for KFP components. This package is part of the KFP SDK ecosystem (version 2.16.0) and is typically released in sync with `kfp`, `kfp-server-api`, and `kfp-pipeline-spec` with frequent updates.","status":"active","version":"2.16.0","language":"en","source_language":"en","source_url":"https://github.com/kubeflow/pipelines/tree/master/kubernetes_platform/python","tags":["kubeflow","kubernetes","kfp","pipelines","mlops","machine-learning"],"install":[{"cmd":"pip install kfp-kubernetes==2.16.0","lang":"bash","label":"Install specific version"}],"dependencies":[{"reason":"Main KFP SDK, often used together for pipeline definition and compilation.","package":"kfp","optional":true},{"reason":"KFP client API for interacting with the KFP backend.","package":"kfp-server-api","optional":true},{"reason":"Provides the pipeline definition specification.","package":"kfp-pipeline-spec","optional":true}],"imports":[{"note":"While `kfp.kubernetes` exists, `kfp-kubernetes` provides its own set of utilities, especially for KFP SDK v2. Direct import from `kfp_kubernetes.common` is recommended for explicit usage of this library's features.","wrong":"from kfp.kubernetes import common","symbol":"common","correct":"from kfp_kubernetes import common"},{"symbol":"KubernetesPlatformConfig","correct":"from kfp_kubernetes.kfp_kubernetes_platform import KubernetesPlatformConfig"}],"quickstart":{"code":"import kfp\nfrom kfp import dsl\nfrom kfp_kubernetes import common\n\n# Define a simple KFP component\n@dsl.component\ndef hello_world_op(name: str) -> str:\n    import os\n    print(f\"Hello, {name} from pod {os.environ.get('KUBERNETES_POD_NAME', 'unknown')}!\")\n    return f\"Hello, {name}!\"\n\n# Create a pipeline\n@dsl.pipeline(name=\"kubernetes-config-pipeline\")\ndef kubernetes_config_pipeline():\n    task = hello_world_op(name=\"World\")\n\n    # Add a Kubernetes volume to the component's pod\n    # This assumes an existing PVC named 'my-data-pvc' on your cluster\n    common.add_volume_to_component(\n        task,\n        volume_name=\"my-data-volume\",\n        mount_path=\"/mnt/data\",\n        existing_pvc_name=\"my-data-pvc\"\n    )\n\n    # Add a node selector to schedule the task on a specific node\n    common.add_node_selector_to_component(task, \"kubernetes.io/hostname\", \"my-worker-node-label\")\n\n    # Add a toleration to allow scheduling on tainted nodes\n    common.add_toleration_to_component(task, \"key\", \"value\", \"Equal\", \"NoSchedule\")\n\n# Compile the pipeline (requires kfp to be installed)\nif __name__ == \"__main__\":\n    try:\n        kfp.compiler.Compiler().compile(kubernetes_config_pipeline, \"kubernetes_config_pipeline.yaml\")\n        print(\"Pipeline compiled successfully to kubernetes_config_pipeline.yaml\")\n    except Exception as e:\n        print(f\"Error compiling pipeline: {e}\")\n","lang":"python","description":"This example demonstrates how to define a KFP pipeline and use `kfp_kubernetes.common` functions to add Kubernetes-specific configurations like a volume, node selector, and toleration to a component. This pipeline requires a KFP SDK v2 compatible environment for execution and an existing PVC named 'my-data-pvc' on the Kubernetes cluster."},"warnings":[{"fix":"Migrate pipeline code to KFP SDK v2. Use functions from `kfp_kubernetes.common` (e.g., `add_volume_to_component`) or `kfp.kubernetes` module functions (if directly provided by the `kfp` package itself) on `dsl.Task` objects.","message":"The KFP SDK v2 introduced significant API changes for configuring components, replacing direct manipulation of `ContainerOp` attributes (common in KFP v1) with utility functions or decorators.","severity":"breaking","affected_versions":"KFP SDK v2.0.0 onwards"},{"fix":"Always install all KFP SDK related packages with the same exact version string, e.g., `pip install kfp==2.16.0 kfp-kubernetes==2.16.0 kfp-server-api==2.16.0 kfp-pipeline-spec==2.16.0`.","message":"Ensuring strict version alignment between `kfp-kubernetes`, `kfp`, `kfp-server-api`, and `kfp-pipeline-spec` is critical. Mismatched versions can lead to runtime errors, unexpected behavior, or incorrect Kubernetes manifest generation.","severity":"gotcha","affected_versions":"All KFP SDK v2.x versions"},{"fix":"Review your Kubeflow cluster's object store configuration. Ensure your pipeline's volume configurations (e.g., via `add_volume_to_component`) are compatible with the deployed object store or explicitly configure your preferred storage solution.","message":"Starting with KFP 2.15.0, the default object store deployment for new installations changed from MinIO to SeaweedFS. Existing installations or specific configurations might still use MinIO, but this change can affect how persistent volumes are expected to be managed.","severity":"gotcha","affected_versions":"KFP SDK v2.15.0 and later"},{"fix":"Validate the generated Kubernetes YAML (e.g., `kubernetes_config_pipeline.yaml`) and ensure your cluster has the necessary resources, permissions (RBAC), node labels/taints, and storage classes to support the requested configurations.","message":"While `kfp-kubernetes` helps generate Kubernetes manifests for pipeline components, the final execution is dependent on the actual Kubernetes cluster configuration. Discrepancies (e.g., missing StorageClasses, incorrect node labels, RBAC permissions) can cause pipeline failures.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Update your pipeline code to KFP v2 syntax. For Kubernetes configurations, import `common` from `kfp_kubernetes` and use functions like `common.add_node_selector_to_component(task, key, value)` on your `dsl.Task` object.","cause":"Attempting to use KFP v1 syntax (`ContainerOp`) with KFP v2. KFP v1 `ContainerOp` objects had direct methods for Kubernetes config, but KFP v2's `dsl.Task` (or equivalent) uses external utility functions.","error":"AttributeError: 'ContainerOp' object has no attribute 'add_node_selector'"},{"fix":"Run `pip install kfp-kubernetes` or `pip install kfp-kubernetes==X.Y.Z` ensuring the version matches your installed KFP SDK to resolve the missing module.","cause":"The `kfp-kubernetes` package is either not installed or not installed correctly within your Python environment, preventing the import of its modules.","error":"ModuleNotFoundError: No module named 'kfp_kubernetes.common'"},{"fix":"Consult the official `kfp-kubernetes` documentation or its source code for the correct function signature and required arguments. For `add_volume_to_component`, `volume_name` and `mount_path` are typically mandatory.","cause":"The utility function `kfp_kubernetes.common.add_volume_to_component` (or similar) was called with an incorrect number or type of arguments, or the arguments were out of order.","error":"TypeError: add_volume_to_component() missing 1 required positional argument: 'mount_path'"},{"fix":"Verify the status and configuration of the object store on your Kubeflow cluster. If using KFP 2.15.0 or later, ensure SeaweedFS is operational, or explicitly configure your pipeline to use an alternative, correctly set up S3-compatible store or MinIO.","cause":"The KFP pipeline is configured to use an object storage solution (e.g., MinIO, SeaweedFS) that is either not deployed, incorrectly configured, or inaccessible on the underlying Kubeflow cluster. This is often related to the default object store change in KFP 2.15.0.","error":"Error: \"The requested object store is not supported or not configured.\" (exact message may vary)"}]}