Search code examples
testinggoogle-cloud-platformgoogle-cloud-runtrafficrevision

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

  • 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