Tags provide a way to create business attributes for projects to logically
organize them. You create tag key-value pairs to provide a mechanism to group
projects based on characteristics you define. For example, you can create a tag
with the key ENV and the value prod to indicate the project is in a
production environment.
This document is for IT administrators within the platform administrator group, who are responsible for organizing and managing projects in a Google Distributed Cloud (GDC) air-gapped universe. For more information, see Audiences for GDC air-gapped documentation.
Before you begin
To get the permissions that you need to create a tag, ask your Organization IAM Admin to grant you the Tag Admin (
tag-admin) role.Set an environment variable for the zonal management API server kubeconfig file:
export KUBECONFIG=MANAGEMENT_API_SERVERReplace
MANAGEMENT_API_SERVERwith the path to the kubeconfig file for the zonal management API server. For more information about generating a kubeconfig file for the API server in your targeted zone, see Zonal management API server resources.Review the following tag key-value pair rules before creating a tag:
- Tag key names must be unique within a GDC zone.
- Tag value names can be the same, as long as they're attached to different tag keys.
- Tag key names must not contain the string
-tv. - Tag value names must not contain the string
tv-. - The following rules apply to both keys and values:
- Maximum of 25 characters in length.
- Contains only letters, numbers, hyphens.
- Starts with a letter.
- Must not start with the prefix
g-, such asg-project. - Must not contain the string
-tv-. - Must not end with the string
-system. The-systemsuffix is reserved for tags created by the GDC system.
Create a tag key-value pair
To create a tag key-value pair, complete the following steps:
Create and apply the
TagKeycustom resource to theplatformnamespace:kubectl apply -f --kubeconfig ${KUBECONFIG} - <<EOF apiVersion: resourcemanager.gdc.goog/v1alpha1 kind: TagKey metadata: name: TAG_KEY_NAME namespace: platform spec: {} EOFReplace
TAG_KEY_NAMEwith the name of the tag key.Create and apply the
TagValuecustom resource to the tag key:kubectl apply -f --kubeconfig ${KUBECONFIG} - <<EOF apiVersion: resourcemanager.gdc.goog/v1alpha1 kind: TagValue metadata: name: TAG_VALUE_NAME namespace: g-t-TAG_KEY_NAME spec: {} EOFReplace the following:
TAG_VALUE_NAME: the name of the tag value.TAG_KEY_NAME: the name of the tag key you created in the previous step. The namespace for the tag value must be set to the system-created tag key management namespace.
Verify the new tag key is available:
kubectl get tagkey TAG_KEY_NAME \ --kubeconfig ${KUBECONFIG} \ --namespace platformThe output is similar to the following:
NAME AGE my-tagkey 5mVerify the new tag value is available:
kubectl get tagvalue TAG_VALUE_NAME \ --kubeconfig ${KUBECONFIG} \ --namespace g-t-TAG_KEY_NAMEThe output is similar to the following:
NAME AGE my-tagvalue 6m
After you create a tag key-value pair, you must add it to a project for the tag to take effect.