$ kn service update <service_name> --tag @latest=example-tag
The Knative (kn
) CLI supports traffic operations on the traffic block of a service as part of the kn service update
command.
The following table displays a summary of traffic splitting flags, value formats, and the operation the flag performs. The Repetition column denotes whether repeating the particular value of flag is allowed in a kn service update
command.
Flag | Value(s) | Operation | Repetition |
---|---|---|---|
|
|
Gives |
Yes |
|
|
Gives |
Yes |
|
|
Gives |
No |
|
|
Gives |
Yes |
|
|
Gives |
No |
|
|
Removes |
Yes |
All traffic-related flags can be specified using a single kn service update
command. kn
defines the precedence of these flags. The order of the flags specified when using the command is not taken into account.
The precedence of the flags as they are evaluated by kn
are:
--untag
: All the referenced revisions with this flag are removed from the traffic block.
--tag
: Revisions are tagged as specified in the traffic block.
--traffic
: The referenced revisions are assigned a portion of the traffic split.
You can add tags to revisions and then split traffic according to the tags you have set.
Assigning a --tag
flag to a service by using the kn service update
command creates a custom URL for the revision that is created when you update the service. The custom URL follows the pattern https://<tag>-<service_name>-<namespace>.<domain>
or http://<tag>-<service_name>-<namespace>.<domain>
.
The --tag
and --untag
flags use the following syntax:
Require one value.
Denote a unique tag in the traffic block of the service.
Can be specified multiple times in one command.
The following example assigns the tag latest
to a revision named example-revision
:
$ kn service update <service_name> --tag @latest=example-tag
You can remove a tag to remove the custom URL, by using the --untag
flag.
If a revision has its tags removed, and it is assigned 0% of the traffic, the revision is removed from the traffic block entirely. |
The following command removes all tags from the revision named example-revision
:
$ kn service update <service_name> --untag example-tag