Skip to content

Commit 766deb6

Browse files
authored
Merge pull request PrefectHQ#3046 from emcake/k8s-customize-yaml
allow customization of the yaml template
2 parents 5c26467 + 7aa727a commit 766deb6

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

changes/pr3046.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
enhancement:
2+
- "Allow for setting path to a custom job YAML spec on the Kubernetes Agent - [#3046](https://github.com/PrefectHQ/prefect/pull/3046)"
3+
4+
contributor:
5+
- "[emcake](https://github.com/emcake)"

src/prefect/agent/kubernetes/agent.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ def replace_job_spec_yaml(self, flow_run: GraphQLResult, image: str) -> dict:
157157
container registry, such as Amazon ECR.
158158
- `SERVICE_ACCOUNT_NAME`: name of a service account to run the job as.
159159
By default, none is specified.
160+
- `YAML_TEMPLATE`: a path to where the YAML template should be loaded from. defaults
161+
to the embedded `job_spec.yaml`.
160162
161163
Args:
162164
- flow_run (GraphQLResult): A flow run object
@@ -165,7 +167,10 @@ def replace_job_spec_yaml(self, flow_run: GraphQLResult, image: str) -> dict:
165167
Returns:
166168
- dict: a dictionary representation of a k8s job for flow execution
167169
"""
168-
with open(path.join(path.dirname(__file__), "job_spec.yaml"), "r") as job_file:
170+
yaml_path = os.getenv(
171+
"YAML_TEMPLATE", path.join(path.dirname(__file__), "job_spec.yaml")
172+
)
173+
with open(yaml_path, "r") as job_file:
169174
job = yaml.safe_load(job_file)
170175

171176
identifier = str(uuid.uuid4())[:8]

0 commit comments

Comments
 (0)