This message was deleted.
# marvin-in-the-wild
s
This message was deleted.
m
Let me check the Prefect docs for how to create a Kubernetes WorkPool and add a kubeconfig file as a block via the Prefect 2.0 API. I'll get back to you with the information I find. Here's the step-by-step to create a Kubernetes work pool with a kubeconfig file as a block using Prefect 2.0, without the UI: 1. Install Prefect CLI: Make sure you have Prefect installed. 2. Create the Work Pool: Use the CLI or API to create the work pool. Step-by-step instructions: ### Step 1: Install Prefect CLI Ensure Prefect is installed and you are logged in.
Copy code
bash
pip install prefect
prefect login
### Step 2: Create a Work Pool Use the Prefect CLI to create a Kubernetes work pool.
Copy code
bash
prefect work-pool create "kubernetes" --type kubernetes
### Step 3: Add Kubeconfig Block To add a Kubeconfig block, you need to use the Prefect API:
Copy code
python
from prefect.client.cloud import CloudClient

client = CloudClient()

# Create a kubeconfig block
kubeconfig_data = """YOUR_KUBECONFIG_FILE_CONTENT"""
block_response = client.create_block({
    "name": "kubeconfig-block",
    "slug": "kubeconfig-block",
    "data": kubeconfig_data,
    "block_type": "kubernetes",
})

block_id = block_response["id"]

# Update the work pool to use this kubeconfig block
# Assuming work_pool_id is the ID of your created work pool
work_pool_id = "your_work_pool_id"
client.update_work_pool(work_pool_id, {
    "kubeconfig_block_id": block_id
})
Replace
YOUR_KUBECONFIG_FILE_CONTENT
with the actual content of your kubeconfig file, and
your_work_pool_id
with the ID of your created work pool. ### Helpful Links: - Work Pools in Prefect 2.0 - Kubernetes Deployment Guides If you need further assistance or run into issues, please let me know!
n
hey @Marco Ruta - just as a heads up, unless you’re changing server side behavior, you should only generally use client schemas, not server schemas so that import above, you’ll want to swap server->client
1
m
@Nate thank you! I'm still trying to create a k8s workpool using python SDK and creating the workpool before and then adding the kube config block ... do you know other way to do that? Maybe some method that have "kube_config" as parameter 😄