lowing snippet will prove useful:

import requestsfrom zenml.client import Client

from zenml.integrations.kubeflow.flavors.kubeflow_orchestrator_flavor import (

KubeflowOrchestratorSettings,

NAMESPACE = "namespace_name"  # This is the user namespace for the profile you want to use

USERNAME = "admin"  # This is the username for the profile you want to use

PASSWORD = "abc123"  # This is the password for the profile you want to use

# Use client_username and client_password and ZenML will automatically fetch a session cookie

kubeflow_settings = KubeflowOrchestratorSettings(

client_username=USERNAME,

client_password=PASSWORD,

user_namespace=NAMESPACE

# You can also pass the cookie in `client_args` directly

# kubeflow_settings = KubeflowOrchestratorSettings(

#     client_args={"cookies": session_cookie}, user_namespace=NAMESPACE

# )

@pipeline(

settings={

"orchestrator.kubeflow": kubeflow_settings

...

if "__name__" == "__main__":

# Run the pipeline

Note that the above is also currently not tested on all Kubeflow versions, so there might be further bugs with older Kubeflow versions. In this case, please reach out to us on Slack.

Using secrets in settings

The above example encoded the username and password in plain text as settings. You can also set them as secrets.

zenml secret create kubeflow_secret \

--username=admin \

--password=abc123

And then you can use them in code:

# Use client_username and client_password and ZenML will automatically fetch a session cookie

kubeflow_settings = KubeflowOrchestratorSettings(

client_username="{{kubeflow_secret.username}}",  # secret reference

client_password="{{kubeflow_secret.password}}",  # secret reference

user_namespace="namespace_name"

See full documentation of using ZenML secrets here.

For more information and a full list of configurable attributes of the Kubeflow orchestrator, check out the SDK Docs .

PreviousLocal Docker Orchestrator

NextKubernetes Orchestrator

Last updated 19 days ago