Alan
02/04/2025, 5:55 PM2.19.3 (2024.5.30190018)
, specifically regarding the baseJobTemplate. I understand that I have to pass a JSON string to that, however, everytime, the helm install tries to create a default base job configmap and tries to attach it to my helm release. Any idea what is going on?
## Deployment Configuration
worker:
# -- unique cluster identifier, if none is provided this value will be infered at time of helm install
clusterUid: ""
image:
# -- worker image repository
repository: prefecthq/prefect
## prefect tag is pinned to the latest available image tag at packaging time. Update the value here to
## override pinned tag
# -- prefect image tag (immutable tags are recommended)
prefectTag: 2.19.3-python3.11-kubernetes
# -- worker image pull policy
pullPolicy: IfNotPresent
## Optionally specify an array of imagePullSecrets.
## Secrets must be manually created in the namespace.
## ref: <https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/>
## e.g:
## pullSecrets:
## - myRegistryKeySecretName
# -- worker image pull secrets
pullSecrets: []
# -- enable worker image debug mode
debug: false
## general configuration of the worker
config:
# -- the work pool that your started worker will poll.
workPool: ""
# -- one or more work queue names for the worker to pull from. if not provided, the worker will pull from all work queues in the work pool
workQueues: []
# -- how often the worker will query for runs
queryInterval: 5
# -- when querying for runs, how many seconds in the future can they be scheduled
prefetchSeconds: 10
# -- connect using HTTP/2 if the server supports it (experimental)
http2: true
## You can set the worker type here.
## The default image includes only the type "kubernetes".
## Custom workers must be properly registered with the prefect cli.
## See the guide here: <https://docs.prefect.io/2.11.3/guides/deployment/developing-a-new-worker-type/>
# -- specify the worker type
type: kubernetes
## one of 'always', 'if-not-present', 'never', 'prompt'
# -- install policy to use workers from Prefect integration packages.
installPolicy: prompt
# -- the name to give to the started worker. If not provided, a unique name will be generated.
name: null
# -- maximum number of flow runs to start simultaneously (default: unlimited)
limit: null
# -- JSON formatted base job template. If unspecified, Prefect will use the default base job template for the given worker type. If the work pool already exists, this will be ignored.
baseJobTemplate: ${BASE_JOB_TEMPLATE}
Jamie Zieziula
02/04/2025, 6:14 PMJamie Zieziula
02/04/2025, 6:17 PMJamie Zieziula
02/04/2025, 6:17 PMAlan
02/04/2025, 6:54 PMbaseJobTemplate: ${BASE_JOB TEMPLATE}
, which I am using in a helm release in terraform:
resource "helm_release" "prefect_worker_gpu" {
for_each = { for np in var.karpenter_node_pools_gpu : np.node_pool_name => np }
name = "prefect-worker-${each.value.workpool_name}"
namespace = "${var.environment}-prefect"
chart = "prefect-worker"
repository = "<https://prefecthq.github.io/prefect-helm>"
version = "${var.prefect_chart_version}"
values = [templatefile("${path.module}/values/values-worker.yaml", {
UI_URL = "<https://prefect>-${var.product_name}-${var.environment}.**.com"
EXISTING_SECRET = "${kubernetes_secret.db_secret.metadata[0].name}"
CERTIFICATE_ARN = "${data.aws_acm_certificate.env.arn}"
SECURITY_GROUP = "${var.prefect_security_group_id}"
API_URL = "<http://prefect-server>.${var.environment}-prefect.svc.cluster.local:4200/api"
WORK_POOL_NAME = "${each.value.workpool_name}"
FULL_NAME_OVERRIDE = "prefect-worker-${each.value.workpool_name}"
IS_INITIAL = false
BASE_JOB_TEMPLATE = jsonencode(templatefile("${path.module}/values/baseJobTemplateGPU.json.tpl", {
prefect_hq_version = "${var.prefect_hq_version}"
environment = "${var.environment}"
node_pool_name = "${each.value.node_pool_name}"
num_gpus = "${each.value.num_gpus}"
}))
})]
depends_on = [ helm_release.prefect_server, kubernetes_config_map.base_job_template_gpu, kubernetes_config_map.base_job_template_cpu, kubernetes_namespace.prefect, kubernetes_secret.prefect_api_key ]
}
Alan
02/04/2025, 6:56 PMresource "helm_release" "prefect_worker_cpu" {
for_each = { for np in var.karpenter_node_pools_cpu : np.node_pool_name => np }
name = "prefect-worker-${each.value.workpool_name}"
namespace = "${var.environment}-prefect"
chart = "prefect-worker"
repository = "<https://prefecthq.github.io/prefect-helm>"
version = "${var.prefect_chart_version}"
values = [templatefile("${path.module}/values/values-worker.yaml", {
UI_URL = "<https://prefect>-${var.product_name}-${var.environment}.*.com"
EXISTING_SECRET = "${kubernetes_secret.db_secret.metadata[0].name}"
CERTIFICATE_ARN = "${data.aws_acm_certificate.env.arn}"
SECURITY_GROUP = "${var.prefect_security_group_id}"
API_URL = "<http://prefect-server>.${var.environment}-prefect.svc.cluster.local:4200/api"
WORK_POOL_NAME = "${each.value.workpool_name}"
FULL_NAME_OVERRIDE = "prefect-worker-${each.value.workpool_name}"
IS_INITIAL = false
BASE_JOB_TEMPLATE = jsonencode(templatefile("${path.module}/values/baseJobTemplateCPU.json.tpl", {
prefect_hq_version = "${var.prefect_hq_version}"
environment = "${var.environment}"
node_pool_name = "${each.value.node_pool_name}"
}))
})]
depends_on = [ helm_release.prefect_server, kubernetes_config_map.base_job_template_gpu, kubernetes_config_map.base_job_template_cpu, kubernetes_namespace.prefect, kubernetes_secret.prefect_api_key ]
}
Alan
02/04/2025, 6:58 PMError: context deadline exceeded
with module.prefect.helm_release.prefect_worker_gpu["karpenter-nodepool-gpu-2x"],
on tfmodules/prefect/workers.tf line 1, in resource "helm_release" "prefect_worker_gpu":
1: resource "helm_release" "prefect_worker_gpu" {
Error: Unable to continue with install: ConfigMap "prefect-worker-base-job-template" in namespace "dev-prefect" exists and cannot be imported into the current release: invalid ownership metadata; annotation validation error: key "<http://meta.helm.sh/release-name|meta.helm.sh/release-name>" must equal "prefect-worker-work-cpu": current value is "prefect-worker-work-gpu"
with module.prefect.helm_release.prefect_worker_cpu["karpenter-nodepool-cpu-4x"],
on tfmodules/prefect/workers.tf line 27, in resource "helm_release" "prefect_worker_cpu":
27: resource "helm_release" "prefect_worker_cpu" {
For some reason, it is creating its own configmap with the default base job template and trying to associate it to the helm release?!Alan
02/04/2025, 7:05 PMJamie Zieziula
02/04/2025, 7:35 PMJamie Zieziula
02/04/2025, 7:37 PMValues.worker.config.baseJobTemplate.name
Jamie Zieziula
02/04/2025, 7:38 PMAlan
02/04/2025, 7:38 PMAlan
02/04/2025, 7:38 PMJamie Zieziula
02/04/2025, 7:38 PMAlan
02/04/2025, 7:39 PMAlan
02/04/2025, 7:39 PMAlan
02/04/2025, 7:40 PMJamie Zieziula
02/04/2025, 7:42 PMAlan
02/04/2025, 7:43 PMJamie Zieziula
02/04/2025, 7:44 PMworker.image.prefectTag
Alan
02/04/2025, 7:45 PMJamie Zieziula
02/04/2025, 7:46 PMAlan
02/04/2025, 7:47 PMJamie Zieziula
02/04/2025, 7:48 PMAlan
02/04/2025, 9:28 PMAlan
02/04/2025, 9:28 PMJamie Zieziula
02/04/2025, 9:36 PM