HI everyone , I am running into a exception when I...
# prefect-kubernetes
d
HI everyone , I am running into a exception when I am running a job in kubernetes. The error message is:
Copy code
"jobs.batch is forbidden: User \"system:serviceaccount:prefect2-worker-dev:prefect-worker\" cannot create resource \"jobs\" in API group \"batch\" in the namespace \"default\"
How do I change the jobs from being created in default namespace and change it to some other name space?
For more context, I deploy prefect flows using the Prefect Python library.
Copy code
deployment = Deployment.build_from_flow(
        flow=flow,
        name=deployment_name,
        schedule=schedule,
        tags=tags,
        is_schedule_active=is_schedule_active,
        work_pool_name=work_pool_name,
        work_queue_name=work_queue_name,
        infrastructure=KubernetesJob(
            namespace=config.get("INFRA", "KUBERNETES_NAMESPACE") # THIS IS NOT DEFAULT
        ),
        infra_overrides=generate_kubernetes_overrides(
            manifest, environment, mem_limit_gb
        ),
        path=DOCKER_WORK_DIR,
    )
deployment.apply()
And I have deployed prefect workers using hellm from the
prefect-helm
github.
r
try adding the namespace to infra_overrides
infra_overrides["namespace"]=config.get("INFRA", "KUBERNETES_NAMESPACE")
d
Unsure if overriting the existing namespace with the same namspace will make a difference but m testing that out.
r
yeah, the other link more likely
d
Unsure if that is the issue as well. Helm creates service qaccounts by default. Its just that the jobs are being spawns in the wrong name space
r
clusterrolebinding for the sa?
r
sure - not used the helm chart
d
Yes , I deployed previously without the helm charts and they were working - now that i am using helm charts, ive started having these issues