NAME

gcloud run services update-traffic - adjust the traffic assignments for a Cloud Run service

SYNOPSIS

gcloud run services update-traffic [[SERVICE] --namespace=NAMESPACE] [--async] [--platform=PLATFORM; default="managed"] [--clear-tags | --set-tags=[TAG=REVISION,...] | --remove-tags=[TAG,...] --update-tags=[TAG=REVISION,...]] [--region=REGION | --cluster=CLUSTER --cluster-location=CLUSTER_LOCATION | --context=CONTEXT --kubeconfig=KUBECONFIG] [--to-latest | --to-revisions=[REVISION-NAME=PERCENTAGE,...] | --to-tags=[TAG=PERCENTAGE,...]] [GCLOUD_WIDE_FLAG ...]

DESCRIPTION

Adjust the traffic assignments for a Cloud Run service.

EXAMPLES

To assign 10% of traffic to revision myservice-s5sxn and 90% of traffic to revision myservice-cp9kw run:

$ gcloud run services update-traffic myservice \ --to-revisions=myservice-s5sxn=10,myservice-cp9kw=90

To increase the traffic to revision myservice-s5sxn to 20% and by reducing the traffic to revision myservice-cp9kw to 80% run:

$ gcloud run services update-traffic myservice \ --to-revisions=myservice-s5sxn=20

To rollback to revision myservice-cp9kw run:

$ gcloud run services update-traffic myservice \ --to-revisions=myservice-cp9kw=100

To assign 100% of traffic to the current or future LATEST revision run:

$ gcloud run services update-traffic myservice --to-latest

You can also refer to the current or future LATEST revision in --to-revisions by the string "LATEST". For example, to set 10% of traffic to always float to the latest revision:

$ gcloud run services update-traffic myservice \ --to-revisions=LATEST=10

POSITIONAL ARGUMENTS

Service resource - Service to update the configuration of. The arguments in

this group can be used to specify the attributes of this resource.

[SERVICE]

ID of the service or fully qualified identifier for the service. To set the service attribute:

  • provide the argument SERVICE on the command line;

  • specify the service name from an interactive prompt.

--namespace=NAMESPACE

Specific to Cloud Run for Anthos: Kubernetes namespace for the service. To set the namespace attribute:

  • provide the argument SERVICE on the command line with a fully specified name;

  • specify the service name from an interactive prompt with a fully specified name;

  • provide the argument --namespace on the command line;

  • set the property run/namespace;

  • For Cloud Run on Kubernetes Engine, defaults to "default". Otherwise, defaults to project ID.;

  • provide the argument project on the command line;

  • set the property core/project.

FLAGS

--async

Return immediately, without waiting for the operation in progress to complete.

--platform=PLATFORM; default="managed"

Target platform for running commands. Alternatively, set the property [run/platform]. PLATFORM must be one of:

managed

Fully managed version of Cloud Run. Use with the --region flag or set the [run/region] property to specify a Cloud Run region.

gke

Cloud Run for Anthos on Google Cloud. Use with the --cluster and --cluster-location flags or set the [run/cluster] and [run/cluster_location] properties to specify a cluster in a given zone.

kubernetes

Use a Knative-compatible kubernetes cluster. Use with the --kubeconfig and --context flags to specify a kubeconfig file and the context for connecting.

Specify traffic tags. Traffic tags can be assigned to a revision by name or to

the latest ready revision. Assigning a tag to a revision generates a URL prefixed with the tag that allows addressing that revision directly, regardless of the percent traffic specified. Keys are tags. Values are revision names or "LATEST" for the latest ready revision. For example, --set-tags=candidate=LATEST,current=myservice-v1 assigns the tag "candidate" to the latest ready revision and the tag "current" to the revision with name "myservice-v1" and clears any existing tags. Changing tags does not affect the traffic percentage assigned to revisions. When using a tags flag and one or more of --to-latest and --to-revisions in the same command, the tags change occurs first then the traffic percentage change occurs.

At most one of these can be specified:

--clear-tags

Remove all tags.

--set-tags=[TAG=REVISION,...]

List of key-value pairs to set as tags. All existing tags will be removed first.

Only --update-tags and --remove-tags can be used together. If both are

specified, --remove-tags will be applied first.

--remove-tags=[TAG,...]

List of tags to be removed.

--update-tags=[TAG=REVISION,...]

List of key-value pairs to set as tags.

Arguments to locate resources, depending on the platform used.

At most one of these can be specified:

Only applicable if connecting to Cloud Run (fully managed). Specify

--platform=managed to use:

--region=REGION

Region in which the resource can be found. Alternatively, set the property [run/region].

Only applicable if connecting to Cloud Run for Anthos deployed on Google Cloud.

Specify --platform=gke to use:

Cluster resource - Kubernetes Engine cluster to connect to. The arguments in

this group can be used to specify the attributes of this resource. (NOTE) Some attributes are not given arguments in this group but can be set in other ways. To set the project attribute:

provide the argument --cluster on the command line with a fully specified name;

set the property run/cluster with a fully specified name;

specify the cluster from a list of available clusters with a fully specified name;

provide the argument --project on the command line;

set the property core/project.

--cluster=CLUSTER

ID of the cluster or fully qualified identifier for the cluster. To set the cluster attribute:

  • provide the argument --cluster on the command line;

  • set the property run/cluster;

  • specify the cluster from a list of available clusters.

--cluster-location=CLUSTER_LOCATION

Zone in which the cluster is located. Alternatively, set the property [run/cluster_location]. To set the location attribute:

  • provide the argument --cluster on the command line with a fully specified name;

  • set the property run/cluster with a fully specified name;

  • specify the cluster from a list of available clusters with a fully specified name;

  • provide the argument --cluster-location on the command line;

  • set the property run/cluster_location;

  • specify the cluster location from a list of available zones.

Only applicable if connecting to Cloud Run for Anthos deployed on VMware.

Specify --platform=kubernetes to use:

--context=CONTEXT

The name of the context in your kubectl config file to use for connecting.

--kubeconfig=KUBECONFIG

The absolute path to your kubectl config file. If not specified, the colon- or semicolon-delimited list of paths specified by $KUBECONFIG will be used. If $KUBECONFIG is unset, this defaults to ~/.kube/config.

At most one of these can be specified:
--to-latest

True to assign 100 percent of traffic to the 'latest' revision of this service. Note that when a new revision is created, it will become the 'latest' and traffic will be directed to it. Defaults to False. Synonymous with '--to-revisions=LATEST=100'.

--to-revisions=[REVISION-NAME=PERCENTAGE,...]

Comma separated list of traffic assignments in the form REVISION-NAME=PERCENTAGE. REVISION-NAME must be the name for a revision for the service as returned by 'gcloud beta run list revisions'. PERCENTAGE must be an integer percentage between 0 and 100 inclusive. Ex service-nw9hs=10,service-nw9hs=20 Up to 100 percent of traffic may be assigned. If 100 percent of traffic is assigned, the Service traffic is updated as specified. If under 100 percent of traffic is assigned, the Service traffic is updated as specified for revisions with assignments and traffic is scaled up or down down proportionally as needed for revision that are currently serving traffic but that do not have new assignments. For example assume revision-1 is serving 40 percent of traffic and revision-2 is serving 60 percent. If revision-1 is assigned 45 percent of traffic and no assignment is made for revision-2, the service is updated with revsion-1 assigned 45 percent of traffic and revision-2 scaled down to 55 percent. You can use "LATEST" as a special revision name to always put the given percentage of traffic on the latest ready revision.

--to-tags=[TAG=PERCENTAGE,...]

Comma separated list of traffic assignments in the form TAG=PERCENTAGE. TAG must match a traffic tag on a revision of the service. It may match a previously-set tag, or one assigned using the --set-tags or --update-tags flags on this command. PERCENTAGE must be an integer percentage between 0 and 100 inclusive. Up to 100 percent of traffic may be assigned. If 100 percent of traffic is assigned, the service traffic is updated as specified. If under 100 percent of traffic is assigned, the service traffic is updated as specified to the given tags, and other traffic is scaled up or down proportionally. For example, assume the revision tagged next is serving 40 percent of traffic and the revision tagged current is serving 60 percent. If next is assigned 45 percent of traffic and no assignment is made for current, the service is updated with next assigned 45 percent of traffic and current scaled down to 55 percent.

GCLOUD WIDE FLAGS

These flags are available to all commands: --access-token-file, --account, --billing-project, --configuration, --flags-file, --flatten, --format, --help, --impersonate-service-account, --log-http, --project, --quiet, --trace-token, --user-output-enabled, --verbosity.

Run $ gcloud help for details.

NOTES

These variants are also available:

$ gcloud alpha run services update-traffic

$ gcloud beta run services update-traffic