Kubernetes
Executing individual steps in Kubernetes Pods.
Last updated
Was this helpful?
Executing individual steps in Kubernetes Pods.
Last updated
Was this helpful?
ZenML's Kubernetes step operator allows you to submit individual steps to be run on Kubernetes pods.
You should use the Kubernetes step operator if:
one or more steps of your pipeline require computing resources (CPU, GPU, memory) that are not provided by your orchestrator.
you have access to a Kubernetes cluster.
The Kubernetes step operator requires a Kubernetes cluster in order to run. There are many ways to deploy a Kubernetes cluster using different cloud providers or on your custom infrastructure, and we can't possibly cover all of them, but you can check out our cloud guide.
To use the Kubernetes step operator, we need:
The ZenML kubernetes
integration installed. If you haven't done so, run
A Kubernetes cluster
Either installed and running or a remote in your stack.
A as part of your stack. This is needed so that both your orchestration environment and Kubernetes Pods can read and write step artifacts. Check out the documentation page of the artifact store you want to use for more information on how to set that up and configure authentication for it.
We can then register the step operator and use it in our stacks. This can be done in two ways:
Using the local Kubernetes kubectl
client. This client needs to be configured with a configuration context pointing to the remote cluster. The kubernetes_context
configuration attribute must also be configured with the value of that context:
We can then use the registered step operator in our active stack:
Once you added the step operator to your active stack, you can use it to execute individual steps of your pipeline by specifying it in the @step
decorator as follows:
For debugging, it can sometimes be handy to interact with the Kubernetes pods directly via kubectl. To make this easier, we have added the following labels to all pods:
run
: the name of the ZenML run.
pipeline
: the name of the ZenML pipeline associated with this run.
E.g., you can use these labels to manually delete all pods related to a specific pipeline:
For additional configuration of the Kubernetes step operator, you can pass KubernetesStepOperatorSettings
which allows you to configure (among others) the following attributes:
pod_settings
: Node selectors, labels, affinity, tolerations, secrets, environment variables and image pull secrets to apply to the Kubernetes Pods. These can be either specified using the Kubernetes model objects or as dictionaries.
service_account_name
: The name of the service account to use for the Kubernetes Pods.
Using a Service Connector configured to access the remote Kubernetes cluster. Depending on your cloud provider, this should be either an , or service connector. If you're using a Kubernetes cluster that is not provided by any of these, you can use the generic service connector. You can then :
ZenML will build a Docker images which includes your code and use it to run your steps in Kubernetes. Check out if you want to learn more about how ZenML builds these images and how you can customize them.
Check out the for a full list of available attributes and for more information on how to specify settings.
For more information and a full list of configurable attributes of the Kubernetes steop operator, check out the .
Note that if you wish to use this step operator to run steps on a GPU, you will need to follow to ensure that it works. It requires adding some extra settings customization and is essential to enable CUDA for the GPU to give its full acceleration.