This page shows you how to use labels with your Filestore instances. It also describes how to add, update, and delete the labels for an instance. Labels let you group related instances and store metadata about 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 billed charges by label.
Labels can be used as queryable annotations for resources, but can't be used to set conditions on policies. Tags provide a way to conditionally allow or deny policies based on whether a resource has a specific tag. For more information, see the Tags overview.
Labels and tags
Tags are a separate tool that are used to provide fine-grained control over policies. For more information about tags, see the Tags overview.
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 within a single resource. However, you can use the same key with multiple resources.
- Keys must start with a lowercase letter or international character.
These limits apply to the key and value for each label, and to the individual Google Cloud resources that have labels. There is no limit on how many labels you can apply across all resources within a project.
Adding or updating an instance's labels
You can add labels to a Filestore instance when you create the instance. After an instance is created, you can add more labels to the instance, as well as update or delete existing labels.
In the Google Cloud console, go to the Filestore Instances page.
Select the checkbox next to each instance whose labels you want to modify.
Click Show info panel.
Add and update labels as needed:
Operation Instructions Add a label Click Add label and type the key and value for the label. Update a label Update the Value field. You cannot update the Key of an existing label. Delete a label Click Delete item delete next to the label.
Click Save to save your changes once you are finished with your updates.
You can edit the labels of a Filestore instance's by running the
instances update command.
To add new labels or change the values of existing labels, use the
--update-labels flag. To delete one or more labels, use the
--clear-labels flag removes 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
- instance-id is the instance ID of the instance you want to edit.
project-id is the project ID of the Cloud project that contains the Filestore instance. You can skip this flag if the Filestore instance is in the
gclouddefault project. You can set the default project by running:
gcloud config set project project-id
zone is the zone where the Filestore instance resides. Run the
gcloud filestore zones listcommand to get a list of supported zones. You can skip this flag if the Filestore instance is in the
gclouddefault zone. You can set the default zone by running:
gcloud config set filestore/zone zone
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
Services currently supporting labels
The following Google Cloud services support labels today:
- AI Platform
- App Engine (both Flexible and Standard environments)
- Artifact Registry
- Certificate Authority Service
- Cloud Composer
- Cloud Bigtable
- Cloud Deployment Manager
- Cloud Functions
- Cloud Healthcare API
- Cloud Key Management Service
- Cloud Run
- Cloud Spanner
- Cloud SQL
- Cloud Storage
- Compute Engine
- Google Kubernetes Engine
- Resource Manager (projects only)
Learn how to edit other properties of a Filestore instance.