PrefectHQ / prefect-helm

Helm charts for deploying Prefect Services
Apache License 2.0
83 stars 54 forks source link

Allow an existing ConfigMap to be passed for `baseJobTemplate` #340

Closed jamiezieziula closed 1 month ago

jamiezieziula commented 1 month ago

Resolves https://github.com/PrefectHQ/prefect-helm/issues/334

jamiezieziula commented 1 month ago

FYI I tested this locally for the following three use cases:

All three built as expected!

I would consider this a breaking change, since the existing value's schema for the basejobtemplate has been changed. I will cut a release of this tomorrow and explicitly write out the upgrade notes

mitchnielsen commented 1 month ago

Testing (from the templating perspective) looks good from my side:

Click to expand testing notes ### Using `configuration` keyword ```yaml worker: cloudApiConfig: accountId: 123-abc workspaceId: 456-def config: workPool: my-work-pool baseJobTemplate: # Option 1 configuration: | { "variables": { "type": "object", "properties": { "env": { "type": "object", "title": "Environment Variables", "description": "Environment variables to set when starting a flow run.", "additionalProperties": { "type": "string" } }, "name": { "type": "string", "title": "Name", "description": "Name given to infrastructure created by a worker." }, ... } } } ``` ConfigMap includes the provided configuration: ``` $ helm template charts/prefect-worker -f test.values.yaml --show-only templates/configmap.yaml | yq '.data' baseJobTemplate.json: "{\n \"variables\": {\n \"type\": \"object\",\n \"properties\": {\n \"env\": {\n \"type\": \"object\",\n \"title\": \"Environment Variables\",\n \"description\": \"Environment variables to set when starting a flow run.\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"name\": {\n \"type\": \"string\",\n \"title\": \"Name\",\n \"description\": \"Name given to infrastructure created by a worker.\"\n },\n ...\n }\n }\n}\n" ``` Deployment uses the flag and file name: ``` $ helm template charts/prefect-worker -f test.values.yaml --show-only templates/deployment.yaml | yq '.spec.template.spec.containers[0].args' - prefect - worker - start - --type - "kubernetes" - --pool - "my-work-pool" - --install-policy - "prompt" - --base-job-template - baseJobTemplate.json ``` Deployment mounts the volume: ``` $ helm template charts/prefect-worker -f test.values.yaml --show-only templates/deployment.yaml | yq '.spec.template.spec.containers[0].volumeMounts[2]' mountPath: /home/prefect/baseJobTemplate.json name: base-job-template-file subPath: baseJobTemplate.json ``` Deployment specifies the volume: ``` $ helm template charts/prefect-worker -f test.values.yaml --show-only templates/deployment.yaml | yq '.spec.template.spec.volumes[1]' name: base-job-template-file configMap: name: prefect-worker-base-job-template ``` ### Using `existingConfigMapName` ```yaml worker: cloudApiConfig: accountId: 123-abc workspaceId: 456-def config: workPool: my-work-pool baseJobTemplate: existingConfigMapName: my-base-job-template ``` ConfigMap is not deployed: ``` $ helm template charts/prefect-worker -f test.values.yaml --show-only templates/configmap.yaml | yq '.data' Error: could not find template templates/configmap.yaml in chart null ``` Deployment uses the flag and file name: ``` $ helm template charts/prefect-worker -f test.values.yaml --show-only templates/deployment.yaml | yq '.spec.template.spec.containers[0].args' - prefect - worker - start - --type - "kubernetes" - --pool - "my-work-pool" - --install-policy - "prompt" - --base-job-template - baseJobTemplate.json ``` Deployment mounts the volume: ``` $ helm template charts/prefect-worker -f test.values.yaml --show-only templates/deployment.yaml | yq '.spec.template.spec.containers[0].volumeMounts[2]' mountPath: /home/prefect/baseJobTemplate.json name: base-job-template-file subPath: baseJobTemplate.json ``` Deployment specifies the volume: ``` $ helm template charts/prefect-worker -f test.values.yaml --show-only templates/deployment.yaml | yq '.spec.template.spec.volumes[1]' name: base-job-template-file configMap: name: my-base-job-template ``` ### Using neither `configuration` nor `existingConfigMapName` ```yaml worker: cloudApiConfig: accountId: 123-abc workspaceId: 456-def config: workPool: my-work-pool baseJobTemplate: {} ``` ConfigMap is not deployed: ``` $ helm template charts/prefect-worker -f test.values.yaml --show-only templates/configmap.yaml | yq '.data' Error: could not find template templates/configmap.yaml in chart null ``` Deployment does not include the flag arg: ``` $ helm template charts/prefect-worker -f test.values.yaml --show-only templates/deployment.yaml | yq '.spec.template.spec.containers[0].args' - prefect - worker - start - --type - "kubernetes" - --pool - "my-work-pool" - --install-policy - "prompt" ``` Deployment does not volume mount the ConfigMap data: ``` $ helm template charts/prefect-worker -f test.values.yaml --show-only templates/deployment.yaml | yq '.spec.template.spec.containers[0].volumeMounts' - mountPath: /home/prefect name: scratch subPathExpr: home - mountPath: /tmp name: scratch subPathExpr: tmp ``` Deployment does not specify the ConfigMap volume: ``` $ helm template charts/prefect-worker -f test.values.yaml --show-only templates/deployment.yaml | yq '.spec.template.spec.volumes' - name: scratch emptyDir: {} ```