Adding, modifying, and removing tags

Modified: 13 Dec 2022 21:28 UTC

You can manage tags for an individual instance from the instance details page on the Triton portal or by using CloudAPI.

Use cases for tags

Tags are external descriptors added to an instance, which can allow users to identify an instance from a list. Tags are not accessible from inside an instance.

Here are some example scenarios in which you may want to add a tag. This list does not encompass all possibilities.

In some scenarios, tags are automatically added to your instance. For example, Docker containers are assigned the tag key-value pair sdc_docker: true. Docker labels are also interpreted as tags.

To better understand the difference between tags and metadata, view the comparison chart.

Manage tags with the Triton portal

To use the Triton Compute Service portal to manage tags, you must be signed in.

Adding a tag to an instance

  1. Select Compute from the navigation.
  2. Select the instance to be tagged from the list displayed.
  3. Scroll down to the Tags section.
  4. Within the Tags section, specify the key and value for the tag using the corresponding input fields and then click Add.

Editing a tag on an instance

  1. Sign in to your the portal at http://my.mnx.io/
  2. Select Compute from the navigation.
  3. Select the instance on which to edit the tags from the list of instances displayed.
  4. Scroll down to Tags.
  5. Click somewhere on the key/value pair of the tag.
  6. Specify the new key and/or value for the tag using the input fields, and then click Save.

Deleting a tag from an instance

  1. Sign in to your Triton Compute Service dashboard at http://my.mnx.io/.
  2. Select Compute from the navigation.
  3. Select the instance on which to delete a tag from the list of instances displayed.
  4. Scroll down to Tags.
  5. Find the tag to be deleted.
  6. Click on the "X" icon to the right of the key/value pair.

Use CloudAPI to manage tags

To add, modify, and remove tags with CloudAPI, use triton instance tag. To see all of the available options, execute that command with the --help tag.

$ triton instance tag --help

NOTE: Actions executed with triton instance tag are asynchronous. Wait for the update to be complete by adding the -w or --wait option.

View existing tags for an instance

Use triton instance get to list the existing tags on an instance.

$ triton inst get <container> | json tags
{
  "cns": "my-instance"
}

Add tags to an instance

To set tags on a given instance, use set. The results including all existing tags on an instance will be echoed.

$ triton instance tag set -w <container> foo=bar
{
   "cns": "my-instance",
    "foo": "bar"
}

Any pre-existing tags with the same name will be overwritten. For example, if running that command again, using foo as the key name:

$ triton instance tag set -w <container> foo=test
{
   "cns": "my-instance",
    "foo": "test"
}

Remove tags from an instance

To remove tags on an instance, you must only declare the key from the key-value pair with the delete command.

$ triton instance tag delete -w <container> foo
Deleted tag foo on instance <container>

Modify existing tags on an instance

To fully replace all tags on an instance with other given tags, use replace-all.

In the following example, we're replacing the existing key-value pairs.

$ triton instance tag replace-all -w <container> foo=bar group=test
{
    "foo": "bar",
    "group": "test"
}