I ran the command below referring to Shipping the public editor service in Securing Cloud Run services tutorial:
gcloud run deploy editor --image gcr.io/myproject-242723/editor \
--service-account editor-identity \
--set-env-vars EDITOR_UPSTREAM_RENDER_URL=https://renderer-6cl2nkfhva-an.a.run.app \
--allow-unauthenticated
Then, the revision "editor-00001-xaj" is created as shown below:
Now, I want to add the custom revision name "editor-v1.0.0" to a revision when creating it or change the default revision name "editor-00001-xaj" to "editor-v1.0.0". Are there any ways to do it?
As long as I researched, there are no ways to change a revision name but you can add a custom revision name to a revision when creating it.
With this command below:
gcloud run deploy <service>
And the flag below, you can add a custom revision name to a revision when creating it:
--revision-suffix <revision_suffix>
But your custom revision name "editor-v1.0.0" is not allowed for a revision name because a revision name only allows lowercase letters, numbers and hyphen "-" and must begin with a letter and cannot end with hyphen "-" and the maximum length is 63 characters. So "editor-v1.0.0" contains period "." which is not allowed for a revision name. So if you really want to add "editor-v1.0.0" to a revision, change it to "editor-v1-0-0".
Now, you can add the custom revision name "editor-v1-0-0" to a revision when creating it so you need to put only the suffix part "v1-0-0" to the flag as shown below:
--revision-suffix v1-0-0
Then, including the flag above, I run the full command as shown below:
gcloud run deploy editor --image gcr.io/myproject-242723/editor \
--service-account editor-identity \
--set-env-vars EDITOR_UPSTREAM_RENDER_URL=https://renderer-6cl2nkfhva-an.a.run.app \
--allow-unauthenticated \
--revision-suffix v1-0-0 // Here
Now, the custom revision name "editor-v1-0-0" is added to a revision when creating it as shown below:
In addition, if you run the full command mistakenly putting the whole name "editor-v1-0-0" to the flag "--revision-suffix" as shown below:
gcloud run deploy editor --image gcr.io/myproject-242723/editor \
--service-account editor-identity \
--set-env-vars EDITOR_UPSTREAM_RENDER_URL=https://renderer-6cl2nkfhva-an.a.run.app \
--allow-unauthenticated \
--revision-suffix editor-v1-0-0 // Here
The custom revision name "editor-editor-v1-0-0" is added to a revision when creating it as shown below so be careful not to mistakenly put the whole name "editor-v1-0-0" to the flag "--revision-suffix":
In addition again, if you run the full command mistakenly putting the suffix part "v1.0.0" with period "." instead of hyphen "-" to the flag --revision-suffix" as shown below:
gcloud run deploy editor --image gcr.io/myproject-242723/editor \
--service-account editor-identity \
--set-env-vars EDITOR_UPSTREAM_RENDER_URL=https://renderer-6cl2nkfhva-an.a.run.app \
--allow-unauthenticated \
--revision-suffix v1.0.0 // Here
You'll get this error below so be careful not to mistakenly put the suffix part "v1.0.0" with period "." instead of hyphen "-" to the flag --revision-suffix":
ERROR: (gcloud.run.deploy) metadata.name: Resource name must use only lowercase letters, numbers and '-'. Must begin with a letter and cannot end with a '-'. Maximum length is 63 characters.