Filestore provides the option to add labels to your instances. Labels are key-value pairs that you can use to group related instances and store metadata about an instance.
This page explains how you can use labels with your Filestore instances. It also describes how to add, update, and remove the labels for an instance.
What are labels?
A label is a key-value pair that helps you organize your Google Cloud Filestore instances. You can attach a label to each resource, then filter the resources based on their labels. Information about labels is forwarded to the billing system, so you can break down your billing charges by label.
Common uses of labels
We do not recommend creating large numbers of unique labels, such as for timestamps or individual values for every API call. Here are some common use cases for labels:
Team or cost center labels: Add labels based on team or cost center to distinguish Filestore instances owned by different teams (for example,
team:analytics). You can use this type of label for cost accounting or budgeting.
Component labels: For example,
Environment or stage labels: For example,
State labels: For example,
Requirements for labels
The labels applied to a resource must meet the following requirements:
- Each resource can have multiple labels, up to a maximum of 64.
- Each label must be a key-value pair.
- Keys have a minimum length of 1 character and a maximum length of 63 characters, and cannot be empty. Values can be empty, and have a maximum length of 63 characters.
- Keys and values can contain only lowercase letters, numeric characters, underscores, and dashes. All characters must use UTF-8 encoding, and international characters are allowed.
- The key portion of a label must be unique. However, you can use the same key with multiple resources.
- Keys must start with a lowercase letter or international character.
Adding or updating an instance's labels
After you create a Filestore instance, you can add labels to the instance, and also update or delete existing labels.
- Go to the Filestore instances page
- Check the box next to each instance whose labels you want to modify.
- If the Labels panel is not visible, click Show info panel in the upper right corner to open it.
Add and update labels as needed.
To add a new label, click Add label, then type the key and value for the label.
To modify an existing label, update its value. You cannot change the key for an existing label.
To delete an existing label, click the X next to it.
Click Save to save your changes.
Edit an instance's labels by running the
instances update command,
[VALUES_IN_BRACKETS] with the appropriate values. Use the
--update-labels flag to add new labels or change the values of existing
--remove-labels to remove one or more labels, or the
--clear-labels flag to remove all labels from an instance.
gcloud filestore instances update [INSTANCE_ID] \ --project=[PROJECT_ID] \ --zone=[ZONE] \ --update-labels [KEY=VALUE,[KEY=VALUE,…]] \ --remove-labels [KEY,[KEY,…]] \ --clear-labels
where the parameters are as follows:
[INSTANCE_ID]is the identifier for the instance you want to edit.
[PROJECT_ID]is the ID of the GCP project that contains the instance. You can skip this flag if you have set the
gclouddefault project and want to use that.
[ZONE]is the GCP zone in which the Filestore instance resides. Run the
gcloud beta filestore zones listcommand to get a list of supported zones. You can skip this flag if you have set the
gclouddefault zone by running the
gcloud config set filestore/zonecommand.
[KEY]is a new label, or an existing label you want to change or remove.
[VALUE]is the value for a label.
The following example updates the nfs-server instance by adding the status label, updating the dept label value, and removing the admin label.
gcloud filestore instances update nfs-server \ --project=myproject \ --zone=us-central1-c \ --update-labels status=active \ --update-labels dept=accounting \ --remove-labels admin
Learn how to edit other properties of a Filestore instance.