Adding, modifying, and removing metadata

Modified: 26 Jan 2023 22:12 UTC

Metadata is JSON-formatted key/value data that resides on the compute node that hosts the instance. Each container and hardware VM has its own metadata store.

Add metadata to an instance with the help of the Metadata API, on each individual instance page on the Triton portal.

At this time, there are only triton commands for viewing existing metadata and adding metadata to an instance at creation.

There are sdc-* commands available for modifying and deleting metadata, as well as adding metadata to existing instances. However, that requires installing smartdc.

Use cases for metadata

By adding metadata to an instance, you can learn information about an instance from within an instance.

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

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

Manage metadata with the Triton portal

You can manage metadata for an individual instance from the Instance Details page on the portal.

Before proceeding, you must be signed in.

Adding metadata to an instance

  1. Select Compute from the navigation bar.
  2. Select the instance you wish to update from the list displayed.
  3. Scroll down to Metadata.
  4. Within the Metadata section, specify the key and value for the metadata using the corresponding input fields and then click Add.

Editing metadata for an instance

  1. Select Compute from the navigation.
  2. Select the instance on which to edit the tags from the list of instances displayed.
  3. Scroll down to Metadata.
  4. Click somewhere on the key/value pair of the tag.
  5. Specify the new key and/or value for the tag using the input fields, and then click Save.

Deleting metadata from an instance

  1. Select Compute from the navigation.
  2. Select the instance on which to delete a tag from the list of instances displayed.
  3. Scroll down to Metadata.
  4. Find the metadata pair to be deleted.
  5. Click on the "X" icon to the right of the key/value pair.

Use CloudAPI to manage metadata

Once again, triton commands do not exist for modifying or deleting metadata on existing instances. To use sdc-* commands install smartdc:

$ npm install -g smartdc

View existing metadata for an instance

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

$ triton inst get <container> | json metadata
  "foo": "bar"

Create a new instance with metadata

Add metadata when creating a new instance by using the -m or --metadata modifier with each key-value pair.

For example, create an Ubuntu instance with the metadata pairs "foo:bar" and "group:test".

$ triton instance create -m foo=bar -m group=test ubuntu-16.04 g4-highcpu-128M

You can also use -M or --metadata-file to specify that the contents of a file will be loaded as the value of the key.

$ triton instance create -M foo=bar.txt ubuntu-16.04 g4-highcpu-128M

Add and update metadata

To add or update existing metadata, us sdc-updatemachinemetadata with an -m or --metadata modifier associated with each key-value pair.

$ sdc-updatemachinemetadata -m foo=bar -m group=test <container>
  "foo": "bar",
  "group": "test"

Delete metadata

To delete metadata associated with an instance, you must only refer to the key. Delete a single metadata tag with the key foo:

$ sdc-deletemachinemetadata -m=foo <container>

Delete all metadata associated with an instance:

$ sdc-deletemachinemetadata -m='*' <container>