英文:
GCP Create or replace Cloud Run Job
问题
有没有用于创建或替换Cloud Run作业的GCP命令?我正在使用GitHub Actions来创建Cloud Run和调度器作业,并需要在以下命令之间切换:
gcloud alpha run jobs create
和
gcloud alpha run jobs update
有没有一种方法可以创建作业并在已存在时进行覆盖?
英文:
Is there a GCP command for creating OR replacing a cloud run job? I'm using github-actions to create cloud run and scheduler jobs, and need to keep switching the commands between:
gcloud alpha run jobs create
and
gcloud alpha run jobs update
Is there a way to create the job and overwrite it if it already exists?
答案1
得分: 2
gcloud beta run jobs deploy
是最近添加到gcloud中的,它可以完成您寻找的操作。文档在这里。
英文:
gcloud beta run jobs deploy
was recently added to gcloud which does what you're looking for. Documentation is here
答案2
得分: 1
要创建一个Cloud Run新作业:
gcloud beta run jobs create JOB_NAME --image IMAGE_URL OPTIONS
要更新现有作业:
gcloud beta run jobs update JOB_NAME
如果您希望使用单个命令同时处理创建和更新,您可以开发自己的Shell
脚本,示例:
#!/usr/bin/env bash
set -e
set -o pipefail
set -u
export JOB_NAME=my_job
res=$(gcloud beta run jobs describe $JOB_NAME --region=europe-west1 || echo "NOT_EXIST")
echo "#######Result : $res"
if [ "$res" = "NOT_EXIST" ]; then
echo "Creating your job..."
gcloud beta run jobs create $JOB_NAME
else
echo "Updating your job..."
gcloud beta run jobs update $JOB_NAME
fi
英文:
To create a Cloud Run new job :
gcloud beta run jobs create JOB_NAME --image IMAGE_URL OPTIONS
To update existing job :
gcloud beta run jobs update JOB_NAME
If you want a single command to handle the creation and update at the same time, you can develop your own Shell
script, example :
#!/usr/bin/env bash
set -e
set -o pipefail
set -u
export JOB_NAME=my_job
res=$(gcloud beta run jobs describe $JOB_NAME --region=europe-west1 || echo "NOT_EXIST")
echo "#######Result : $res"
if [ "$res" = "NOT_EXIST" ]; then
echo "Creating your job..."
gcloud beta run jobs create $JOB_NAME
else
echo "Updating your job..."
gcloud beta run jobs update $JOB_NAME
fi
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论