Multi-user Isolation for Pipelines

Getting started with Kubeflow Pipelines multi-user isolation

Multi-user isolation for Kubeflow Pipelines is an integration to Kubeflow multi-user isolation.

Refer to Getting Started with Multi-user isolation for the common Kubeflow multi-user operations including the following:

Note, Kubeflow Pipelines multi-user isolation is only supported in the full Kubeflow deployment starting from Kubeflow v1.1 and currently on all platforms except OpenShift. For the latest status about platform support, refer to kubeflow/manifests#1364.

Also be aware that the isolation support in Kubeflow doesn’t provide any hard security guarantees against malicious attempts by users to infiltrate other user’s profiles.

How are resources separated?

Kubeflow Pipelines separates its resources by Kubernetes namespaces (Kubeflow profiles).

Experiments belong to namespaces directly and there’s no longer a default experiment. Runs and recurring runs belong to their parent experiment’s namespace.

Pipeline runs are executed in user namespaces, so that users can leverage Kubernetes namespace isolation. For example, they can configure different secrets for other services in different namespaces.

Other users cannot see resources in your namespace without permission, because the Kubeflow Pipelines API server rejects requests for namespaces that the current user is not authorized to access.

Note, there’s no multi-user isolation for pipeline definitions right now. Refer to Current Limitations section for more details.

When using the UI

When you visit the Kubeflow Pipelines UI from the Kubeflow dashboard, it only shows experiments, runs, and recurring runs in your chosen namespace. Similarly, when you create resources from the UI, they also belong to the namespace you have chosen.

You can select a different namespace to view resources in other namespaces.

When using the SDK

First, you need to connect to the Kubeflow Pipelines public endpoint using the SDK. For Google Cloud, follow these instructions.

When calling SDK methods for experiments, you need to provide the additional namespace argument. Runs, recurring runs are owned by an experiment. They are in the same namespace as the parent experiment, so you can just call their SDK methods in the same way as before.

For example:

  1. import kfp
  2. client = kfp.Client(...) # Refer to documentation above for detailed arguments.
  3. client.create_experiment(name='<Your experiment name>', namespace='<Your namespace>')
  4. print(client.list_experiments(namespace='<Your namespace>'))
  5. client.run_pipeline(
  6. experiment_id='<Your experiment ID>', # Experiment determines namespace.
  7. job_name='<Your job ID>',
  8. pipeline_id='<Your pipeline ID>')
  9. print(client.list_runs(experiment_id='<Your experiment ID>'))
  10. print(client.list_runs(namespace='<Your namespace>'))

To store your user namespace as the default context, use the set_user_namespace method. This method stores your user namespace in a configuration file at $HOME/.config/kfp/context.json. After setting a default namespace, the SDK methods default to use this namespace if no namespace argument is provided.

  1. # Note, this saves the namespace in `$HOME/.config/kfp/context.json`. Therefore,
  2. # You only need to call this once. The saved namespace context will be picked up
  3. # by other clients you use later.
  4. client.set_user_namespace(namespace='<Your namespace>')
  5. print(client.get_user_namespace())
  6. client.create_experiment(name='<Your experiment name>')
  7. print(client.list_experiments())
  8. client.run_pipeline(
  9. experiment_id='<Your experiment ID>', # Experiment determines namespace.
  10. job_name='<Your job name>',
  11. pipeline_id='<Your pipeline ID>')
  12. print(client.list_runs())
  13. # Specifying a different namespace will override the default context.
  14. print(client.list_runs(namespace='<Your other namespace>'))

Note, it is no longer possible to access the Kubeflow Pipelines API service from in-cluster workload directly, read Current Limitations section for more details.

Detailed documentation for the Kubeflow Pipelines SDK can be found in the Kubeflow Pipelines SDK Reference.

When using REST API or generated python API client

Similarly, when calling REST API endpoints or using the generated python API client, namespace argument is required for experiment APIs. Note that namespace is referred to using a resource reference. The resource reference type is NAMESPACE and resource reference key id is the namespace name.

The following example demonstrates how to use the generated Python API client (kf-server-api) in a multi-user environment.

  1. from kfp_server_api import ApiRun, ApiPipelineSpec, \
  2. ApiExperiment, ApiResourceType, ApiRelationship, \
  3. ApiResourceReference, ApiResourceKey
  4. # or you can also do the following instead
  5. # from kfp_server_api import *
  6. experiment=client.experiments.create_experiment(body=ApiExperiment(
  7. name='test-experiment-1234',
  8. resource_references=[ApiResourceReference(
  9. key=ApiResourceKey(
  10. id='<namespace>', # Replace with your own namespace.
  11. type=ApiResourceType.NAMESPACE,
  12. ),
  13. relationship=ApiRelationship.OWNER,
  14. )],
  15. ))
  16. print(experiment)
  17. pipeline = client.pipelines.list_pipelines().pipelines[0]
  18. print(pipeline)
  19. client.runs.create_run(body=ApiRun(
  20. name='test-run-1234',
  21. pipeline_spec=ApiPipelineSpec(
  22. pipeline_id=pipeline.id,
  23. ),
  24. resource_references=[ApiResourceReference(
  25. key=ApiResourceKey(
  26. id=experiment.id,
  27. type=ApiResourceType.EXPERIMENT,
  28. ),
  29. relationship=ApiRelationship.OWNER,
  30. )],
  31. ))
  32. runs=client.runs.list_runs(
  33. resource_reference_key_type=ApiResourceType.EXPERIMENT,
  34. resource_reference_key_id=experiment.id,
  35. )
  36. print(runs)

Current limitations

Resources without isolation

The following resources do not currently support isolation and are shared without access control:

In-cluster API request authentication

Clients can only access the Kubeflow Pipelines API from the public endpoint that enforces authentication.

In-cluster direct access to the API endpoint is denied by Istio authorization policies, because there’s no secure way to authenticate in-cluster requests to the Kubeflow Pipelines API server yet.

If you need to access the API endpoint from in-cluster workload like Jupyter notebooks or cron tasks, current suggested workaround is to connect through public endpoint and follow platform specific documentation to authenticate programmatically using user credentials. For Google Cloud, you can refer to Connecting to Kubeflow Pipelines in a full Kubeflow deployment on Google Cloud.

Last modified 03.03.2021: Move Kubeflow Pipelines under /components (#2505) (c34470b8)