passing container arguments to cloud run job (not service)

Viewed 179

I want to execute a GCP cloud run job (not service) that periodically processes some data. I see that when i configure a cloud run job I can fill out "Container, Variables & Secrets, Connections, Security" field for container arguments. But I want to pass different arguments every time I execute them and I am wondering if there is a way. I haven't been able to find a way to do.

If there is no such way, am I supposed to use cloud run jobs only if I want them to do the same thing periodically?

2 Answers

But I want to pass different arguments every time I execute them and I am wondering if there is a way.

You can update the job before every execution.

I use gcloud CLI tool to run my jobs from a pipeline. I do multiple steps, first I use gcloud beta run jobs update my-job (with updates of variables) and after that I start an execution using gcloud beta run jobs execute my-job.

There is also a flag on the update command, --execute-now that you might want to use to start an execution when you update the job.

As stated in the official documentation:

Unlike a Cloud Run service, which listens for and serves requests, a Cloud Run job only runs its tasks and exits when finished. A job does not listen for or serve requests, and cannot accept arbitrary parameters at execution.

Therefore, there is no way for a Cloud Run job to receive parameters at execution time.


Also note that, at the moment, Cloud Run Jobs is in Preview:

Preview — Using Cloud Run jobs

This feature is covered by the Pre-GA Offerings Terms of the Google Cloud Terms of Service. Pre-GA features might have limited support, and changes to pre-GA features might not be compatible with other pre-GA versions. For more information, see the launch stage descriptions.

Related