Marco Ruta
09/10/2024, 8:06 AMMarvin
09/10/2024, 8:07 AMKubernetesJob
and setting it up accordingly.
- You'll need to make sure you have specific Kubernetes configurations set up, like the kube_config
file.
2. Prefect Documentation Links:
- Work Pools: Prefect Work Pools Documentation
- Kubernetes Integration: Prefect Kubernetes Guide
3. Using Python SDK:
python
from prefect.infrastructure import KubernetesJob
from prefect.functions import create_work_pool
kubernetes_job = KubernetesJob(
name="my-k8s-work-pool",
namespace="default",
job_template_path="path/to/your/job_template.yaml" # Modify as per your job template
)
create_work_pool(
name="my-k8s-work-pool",
infrastructure=kubernetes_job,
kube_config_path="path/to/your/kube_config.yaml" # Specify your kube config file
)
4. REST API:
You can interact with the Prefect REST API to configure the work pool.
Example: POST request to /work_pools
endpoint with the appropriate data.
json
{
"name": "my-k8s-work-pool",
"type": "kubernetes",
"kubernetes_options": {
"kubeconfig_path": "path/to/your/kube_config.yaml"
}
}
Use these resources and examples to set up your Kubernetes work pool on a self-hosted Prefect server using the Prefect 2.x version.
Sources:
- Prefect Work Pools
- Kubernetes Guide