'Is there a way to test a fully-managed Cloud Run revision before sending traffic to it?
I use Google's Cloud Run (fully managed) to run an app that I'm building. When I deploy a new revision, I'd like to be able to verify that various health checks are ok before I start sending it traffic, but I haven't been able to find a URL for individual (traffic-less) revisions. Is there anything similar to what I'm looking for?
Solution 1:[1]
This is possible using "Revision tags", a feature currently in alpha:
By creating a tag latest
that always point to the latets revision, you will be able to access it under the URL https://latest---<SERVICE>-<HASH>.a.run.app
.
To do so, use this command:
gcloud alpha run services update-traffic --update-tags latest=LATEST
When deploying, make sure to not migrate traffic to the new revision with:
gcloud run deploy --image ... --no-traffic
After testing the newly created revision, send 10% of the traffic traffic to it with
gcloud alpha run services update-traffic --to-tags latest=10
Solution 2:[2]
Yes, you can test a new revision before sending traffic to it.
Now, there is the current revision "editor-v1-0-0":
First, to test a new revision by opening the url, you need to add a tag to a new revision. So, to add a tag to a new revision, add the flag as shown below to the command which creates a new revision (It's also possible to add a tag to a new revision with both command and GUI even after creating a new revision):
--tag <tag>
Now, I'll add the tag "green" to a revision:
--tag green
Second, not to send any traffic to a new revision after creating it, you also need to add the flag as shown below to the command (You cannot use this flag with the command if no revisions exist when creating a new revision):
--no-traffic
Then, including 2 flags above, I run the full command referring to Shipping the public editor service in Securing Cloud Run services tutorial as shown below to create a new revision with "editor:2.0.0" image:
gcloud run deploy editor --image gcr.io/myproject-318173/editor:2.0.0 \
--service-account editor-identity \
--set-env-vars EDITOR_UPSTREAM_RENDER_URL=https://renderer-4bdlubpdxq-an.a.run.app \
--allow-unauthenticated \
--revision-suffix v2-0-0 \
--tag green \
--no-traffic
Now, the new revision "editor-v2-0-0" is created with the tag "green" and "0% Traffic" as shown below:
Then, when clicking on "green" tag of the new revision "editor-v2-0-0":
You can open and test the new revision as shown below before sending traffic to the new revision:
And the URL above is:
https://green---editor-4bdlubpdxq-an.a.run.app
And by clicking on "??":
For example, you can change "green":
To "blue" with GUI:
And you can add more tag "yellow":
And you can also remove the tags:
But if you remove the tag, you cannot open and test the new revision:
In addition, you can also change, add and remove tags by clicking on "?" then "Manage revision URLs (tags)":
Lastly, I posted the answer explaining more about tags so see it if you want to know more about tags.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Steren |
Solution 2 |