Managing labels
Custom labels are pairs in the following format: <label name>=<label value>
. You can label resources so that the cost breakdown file gets a column named label.user_labels.<label name>
. You can assigned multiple labels to each resource.
For example, if all VMs belong to two projects, you can label each VM with project=1
or project=2
. The cost breakdown file will then get the label.user_labels.project
column with the relevant values.
Adding a label
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
Add a label to a service resource:
yc <service name> <resource type> add-labels <resource name or ID> \
--labels <label name>=<label value>
Updating a label
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
Warning
The existing labels (labels
) will be completely overwritten by the ones you provide in your request.
Update a service resource label:
yc <service name> <resource type> update <resource name or ID> \
--labels <label name>=<label value>
Deleting a label
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
Delete a service resource label:
yc <service name> <resource type> remove-labels <resource name or ID> \
--labels <label name>
Examples of label management
Adding a label
Adding a label to a VM:
yc compute instance add-labels cl123g4dridnn5cna6df-yduv --labels project=test
Result:
done (5s)
id: fhm1pr2bu3p45s6ildh7
folder_id: b1g23ga45mev6cljderg
created_at: "2020-08-07T11:29:18Z"
name: cl123g4dridnn5cna6df-yduv
labels:
project: test
zone_id: ru-central1-a
...
Updating a label
Edit a Kubernetes cluster label:
yc managed-kubernetes cluster update k8s-gpu --labels new_lable=test_label
Result:
done (1m36s)
id: cat1hknor2345e6d7rr8
folder_id: b1g23ga45mev6cljderg
created_at: "2020-08-07T11:15:59Z"
name: cluster
labels:
new_lable: test_label
status: RUNNING
...
Deleting a label
Delete a Managed Service for MySQL® cluster label:
yc managed-mysql cluster remove-labels mysql123 --labels my_lable
Result:
id: c1qmjaatlurm2bcoi34i
folder_id: b1g23ga45mev6cljderg
created_at: "2020-08-20T11:53:20.015543Z"
name: mysql123
environment: PRODUCTION
...