Brett
04/21/2023, 5:45 PMKevin Grismore
04/21/2023, 6:20 PMBrett
04/21/2023, 6:37 PMKevin Grismore
04/21/2023, 6:39 PMBrett
04/21/2023, 7:21 PM{
"PYODBC_CONN_STR": {
"valueFrom": {
"secretKeyRef": {
"name": "prefect-env",
"key": "PYODBC_CONN_STR"
}
}
}
}
Kevin Grismore
04/21/2023, 7:27 PMadvanced
and then you can edit it like a typical kubernetes job manifest, including for your env varsBrett
04/27/2023, 2:08 PM{
"key": "value",
"ENVIRONMENT": "dev"
}
Kevin Grismore
04/27/2023, 3:15 PMBrett
04/27/2023, 3:15 PMKevin Grismore
04/27/2023, 3:21 PMBrett
04/27/2023, 3:29 PM{{ env }}
variables in that template.
Could it be under the job_manifest/spec/template/spec/containers/{[env]}
?
"job_manifest": {
"kind": "Job",
"spec": {
"template": {
"spec": {
"containers": [
{
------>> "env": "{{ env }}",
"args": "{{ command }}",
"name": "prefect-job",
"image": "{{ image }}",
"imagePullPolicy": "{{ image_pull_policy }}"
}
],
Kevin Grismore
04/27/2023, 3:42 PM{
"name": "PYODBC_CONN_STR",
"valueFrom": {
"secretKeyRef": {
"key": "PYODBC_CONN_STR",
"name": "prefect-env"
}
}
}
}
self.job_manifest["spec"]["template"]["spec"]["containers"][0]["env"] = [
{"name": k, "value": v} for k, v in self.env.items()
]
env
is expecting just "name": "value"
pairs.env
is inherited from prefect.workers.base.BaseJobConfiguration
, which defines env
like:
class BaseJobConfiguration(BaseModel):
...
env: Dict[str, Optional[str]] = Field(
default_factory=dict,
title="Environment Variables",
description="Environment variables to set when starting a flow run.",
)
{{ env }}
part of the template, but given how this is written, I don't think that would workBrett
04/27/2023, 5:07 PM