question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow use of KubernetesJobEnvironment + S3 storage + KubernetesAgent

See original GitHub issue

Current behavior

As of #2666 , it’s now possible to use non-docker storage with dockerized agents such as KubernetesAgent. This is a super exciting feature!

However, if you are using S3 storage and KubernetesAgent, it seems that it’s not possible to customize the jobs created for flow runs using KubernetesJobEnvironment.

I’ve observed that no errors are generated today (prefect 0.12.0) when you use this combination:

  • S3 storage
  • KubernetesJobEnvironment
  • KubernetesAgent

The agent I’ve created is happily creating jobs in the cluster for flow runs, but the manifests for those jobs are all default values and ignore anything I customize in KubernetesJobEnvironment.

After digging for a bit, I found the root cause. From “Kubernetes Job Environment”:

The KubernetesJobEnvironment accepts an argument job_spec_file which is a string representation of a path to a Kubernetes Job YAML file. On initialization that Job spec file is loaded and stored in the Environment. It will never be sent to Prefect Cloud and will only exist inside your Flow’s Docker storage.

I can also see this in code in KubernetesJobEnvironment.create_flow_run_job(), where the environment explicitly expects a docker image containing the job_spec_file

https://github.com/PrefectHQ/prefect/blob/26518173cf722c742eefcae970260edb5e385f54/src/prefect/environments/execution/k8s/job.py#L116-L149

Proposed behavior

I’d like to be able to store the job_spec_file from KubernetesJobEnvironment in S3 storage, so that the job details of a flow run using S3 storage and run by KubernetesAgent can be customized.

Example

The benefits of non-docker Storage are explained in https://docs.prefect.io/orchestration/execution/storage_options.html#non-docker-storage-for-containerized-environments. Adding this proposed behavior would allow flows using KubernetesAgent to take advantage of that storage without sacrificing the ability to customize the jobs using KubernetesJobEnvironment.

Without this proposed behavior, I think users of KubernetesAgent have to choose between non-docker storage and customizing their jobs.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:8

github_iconTop GitHub Comments

2reactions
espenairminecommented, Jul 10, 2020

Hi, I have a similar request: KubernetesAgent, KubernetesJobEnvironment and storage:GitHub.

I expected the file specified in KubernetesJobEnvironment to be picked up, and prefect register flow validates that it can read the yaml file, but when running from KuvernetesAgent I get Failed to load and execute Flow's environment: FileNotFoundError(2, 'No such file or directory')

1reaction
jameslambcommented, Aug 14, 2020

@joshmeek I think it can be closed, yes.

I haven’t tried with S3 storage since #2950 was merged, but I have been using another non-Docker storage (Webhook) successfully with KubernetesJobEnvironment + a custom spec file for a few days and it’s been working exactly as expected.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Storage Options - Prefect Docs
S3 Storage uses AWS credentials the same way as boto3 which means both upload (build) and download (local agent) times need to have...
Read more >
Use IAM or IRSA with Amazon EKS to restrict access to S3
I want to restrict the access of an Amazon Simple Storage Service (Amazon S3) bucket at the pod level in Amazon Elastic Kubernetes...
Read more >
Prefect 0.14.0: Improved Flow Run Configuration - Medium
To allow users to customize a flow run, we originally added the concept ... you'd use S3 storage, a LocalRun run-config, and a...
Read more >
How to deploy the GitLab Agent for Kubernetes with limited ...
The agentk and the KAS use bidirectional streaming to allow the connection ... kubectl create secret generic -n gitlab-kubernetes-agent ...
Read more >
terraform-aws-modules/s3-bucket/aws
Sometimes you need to have a way to create S3 resources conditionally but Terraform does not allow to use count inside module block,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found