Skip to content

Commit

Permalink
Merge pull request #3046 from emcake/k8s-customize-yaml
Browse files Browse the repository at this point in the history
allow customization of the yaml template
  • Loading branch information
joshmeek authored Aug 25, 2020
2 parents 5c26467 + 7aa727a commit 766deb6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions changes/pr3046.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
enhancement:
- "Allow for setting path to a custom job YAML spec on the Kubernetes Agent - [#3046](https://github.com/PrefectHQ/prefect/pull/3046)"

contributor:
- "[emcake](https://github.com/emcake)"
7 changes: 6 additions & 1 deletion src/prefect/agent/kubernetes/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ def replace_job_spec_yaml(self, flow_run: GraphQLResult, image: str) -> dict:
container registry, such as Amazon ECR.
- `SERVICE_ACCOUNT_NAME`: name of a service account to run the job as.
By default, none is specified.
- `YAML_TEMPLATE`: a path to where the YAML template should be loaded from. defaults
to the embedded `job_spec.yaml`.
Args:
- flow_run (GraphQLResult): A flow run object
Expand All @@ -165,7 +167,10 @@ def replace_job_spec_yaml(self, flow_run: GraphQLResult, image: str) -> dict:
Returns:
- dict: a dictionary representation of a k8s job for flow execution
"""
with open(path.join(path.dirname(__file__), "job_spec.yaml"), "r") as job_file:
yaml_path = os.getenv(
"YAML_TEMPLATE", path.join(path.dirname(__file__), "job_spec.yaml")
)
with open(yaml_path, "r") as job_file:
job = yaml.safe_load(job_file)

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

0 comments on commit 766deb6

Please sign in to comment.