Installation
kubernetes>=21.7,<26- Kubernetes Python clientJinja2- Template engine for Kubernetes manifests
Available Components
The Kubernetes integration provides these stack components:Kubernetes Orchestrator
Execute complete pipelines as Kubernetes Jobs
Kubernetes Step Operator
Run individual steps as Kubernetes Pods
Kubernetes Orchestrator
The Kubernetes orchestrator runs your complete pipeline by creating a Kubernetes Job for each step.Configuration
kubernetes_context- kubectl context name (defaults to current context)kubernetes_namespace- Namespace for pipeline pods (default:zenml)synchronous- Wait for pipeline completion (default:True)skip_local_validations- Skip local kubectl checks (default:False)
Prerequisites
Before using the Kubernetes orchestrator:- Running Kubernetes cluster with kubectl access
- Container registry accessible from the cluster
- kubectl configured with correct context
- Namespace created (if not using default)
Step-Level Pod Configuration
Customize Kubernetes Pods for individual steps usingKubernetesPodSettings:
node_selectors- Select nodes by labelsaffinity- Advanced node selection rulestolerations- Allow scheduling on tainted nodesresources- CPU, memory, and GPU requests/limitsannotations- Pod annotationslabels- Pod labelsvolumes- Volumes to attachvolume_mounts- Where to mount volumesenv- Environment variablesservice_account_name- Kubernetes service accounthost_ipc- Use host IPC namespace (for shared memory)
Resource Management
CPU and Memory:requests- Guaranteed resources, affects schedulinglimits- Maximum resources, container is killed if exceeded
limits, not requests.
Node Selection Strategies
Simple Node Selection:Persistent Storage
Using Persistent Volume Claims:Kubernetes Step Operator
The step operator runs individual steps as Kubernetes Pods, allowing hybrid execution.Configuration
Usage
Service Account Setup
Create a Kubernetes service account for pipelines:Complete Stack Example
Best Practices
Use Resource Quotas
Use Resource Quotas
Prevent resource exhaustion with quotas:
Use Pod Security Standards
Use Pod Security Standards
Apply pod security policies:
Monitor Resource Usage
Monitor Resource Usage
Use metrics-server to monitor resource consumption:
Use Init Containers for Setup
Use Init Containers for Setup
Use init containers for preprocessing:
Common Issues
ImagePullBackOff
ImagePullBackOff
If pods can’t pull images:
- Verify container registry credentials
- Create image pull secret:
- Add to pod settings:
Insufficient Resources
Insufficient Resources
If pods remain pending:
- Check node resources:
kubectl describe nodes - View pod events:
kubectl describe pod POD_NAME -n zenml - Lower resource requests or add more nodes
Permission Denied
Permission Denied
If you see RBAC errors:
- Verify service account exists
- Check role bindings are correct
- Ensure kubectl context has permissions
Next Steps
Kubeflow Integration
Use Kubeflow Pipelines on Kubernetes
Container Registries
Configure image registries
Remote Execution
Production deployment patterns
Kubernetes Docs
Official Kubernetes documentation
