Labels
1. Labels
Projects and folders provide levels of segregation for resources, but what if you want more granularity? That's where labels come in. Labels are a utility for organizing Google Cloud resources. Labels are key-value pairs that you can attach to your resources, like VMs, disks, snapshots and images. You can create and manage labels using the Google Cloud console, gcloud, or the Resource Manager API, and each resource can have up to 64 labels. For example, you could create a label to define the environment of your virtual machines. Then you define the label for each of your instances as either production or test. Using this label, you could search and list all your production resources for inventory purposes. Labels can also be used in scripts to help analyze costs or to run bulk operations on multiple resources. The screenshot shows an example of 4 labels that are created on an instance. Let's go over some examples of what to use labels for: I recommend adding labels based on team or cost center to distinguish instances owned by different teams. You can use this type of label for cost accounting or budgeting. For example, team:marketing and team:research. You can also use labels to distinguish components. For example, component:redis, and component:frontend. Again, you can label based on environment or stage. You should also consider using labels to define an owner or a primary contact for a resource. For example, owner:gaurav, or contact:opm. Or add labels to your resources to define their state. For example, state:inuse, or state:readyfordeletion. It's important to not confuse labels with network tags. Labels, we just learned, are user-defined strings in key-value format that are used to organize resources, and they can propagate through billing. Network tags, on the other hand, are user-defined strings that are applied to instances only and are mainly used for networking, such as applying firewall rules and custom static routes. For more information about using labels, see the link in the Course Resources.2. Let's practice!
Create Your Free Account
or
By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.