Hi there, I migrating from Prefect 2.6 to 3.1 I've...
# ask-community
p
Hi there, I migrating from Prefect 2.6 to 3.1 I've manage to make all updates, the missing part is the creation of workpools using Kubernetes. I've successfuly created a
KubernetesClusterConfig
and
KubernetesJob
using
prefect_kubernetes
. But when I try to create the work pool using:
Copy code
from prefect_kubernetes.jobs import KubernetesJob
# prefect.infrastructure:KubernetesJob has been removed

KubernetesJob.load("k8s-job").publish_as_work_pool()
I've got:
Copy code
AttributeError: 'KubernetesJob' object has no attribute 'publish_as_work_pool'
I am following: https://docs.prefect.io/3.0/resources/upgrade-agents-to-workers Prefect versions:
Copy code
prefect-kubernetes = "^0.5.3"
prefect = "3.1.2"
Any tips?
n
hi @Patrick Alves - yeah sorry this is a bit confusing, but
prefect_kubernetes.jobs.KubernetesJob
is not an infra block like
prefect.infrastructure.KubernetesJob
so you'd have to use the latter which is an infra block and has that publish_as_work_pool method
as you mention, its been removed in later versions of the SDK, so you'd have to downgrade to use it
p
Hi @Nate, thanks for the answer. Considering it was removed, what would be the recomended approach to create a work pool for K8s?
n
publish_as_work_pool is just meant to save the effort of copying your config from your k8s infra block to a work pool but you can always just create a k8s work pool with the UI or CLI and fill in the same config
p
Got it, I will try. Thanks
p
Hi @Nate I've deployed a kubernetes work pool using helm. I've also added a KubernetesJob and KubernetesClusterConfig Blocks. How can I connect them? so my workflows run on kubernetes?
n
hi @Patrick Alves - are you using 2.x or 3.x? either way if you're using work pools, i would recommend this guide importantly, should only need a work pool (base job config etc) and then to run the worker helm chart in older 2.x you needed a
KubernetesJob
infrastructure block but we've deprecated that deployment paradigm in favor of work pools and workers (which should be valid in recent releases of 2.x and all 3.x versions)
p
Thanks @Nate I am using version 3.1.2
n
šŸ‘ definitely that guide and k8s work pool w a worker via helm chart would be my recommendation besides that guide, you might find these examples useful • use the helm chart to install a worker • e2e example in GHA, make a cluster, run a worker against it
āœ… 1