Add and remove tags

Tags provide a way to create business attributes for projects to logically organize them. You add and remove tag key-value pairs to group and ungroup projects based on the changing structure of your project hierarchy.

This document is for IT administrators within the platform administrator group, who are responsible for organizing projects based on existing tag key-value pairs in a GDC universe. For more information, see Audiences for GDC air-gapped documentation.

Before you begin

  1. To get the permissions that you need to add a tag to a project and to remove a tag from a project, ask your Organization IAM Admin to grant you the following roles:

    • TagKey User (tagkey-user)
    • TagValue User (tagvalue-user)
    • Project Editor (project-editor)
  2. Set an environment variable for the zonal management API server kubeconfig file:

    export KUBECONFIG=MANAGEMENT_API_SERVER
    

    Replace MANAGEMENT_API_SERVER with 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.

Add tags to a project

To add a tag to your project, you must bind an existing tag key-value pair that's available in the platform namespace to your project.

  1. Confirm you created a tag key-value pair.

  2. Bind the tag key-value pair to your project:

    kubectl label project PROJECT_NAME \
        --kubeconfig ${KUBECONFIG} \
        --namespace platform \
        tag.resourcemanager.gdc.goog/TAG_KEY_NAME=TAG_VALUE_NAME
    

    Replace the following:

    • PROJECT_NAME: the name of your project to bind the tag key-value pair to.
    • 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.
    • TAG_VALUE_NAME: the name of the tag value.
  3. Verify the tag key-value pair binding is available in your project:

    kubectl get project --kubeconfig ${KUBECONFIG} \
        --namespace platform \
        --label tag.resourcemanager.gdc.goog/TAG_KEY_NAME=TAG_VALUE_NAME
    

    The output is similar to the following:

    NAME           AGE
    my-project     23m
    

Remove tags from a project

To remove a tag from your project, you must remove the tag key label from the project:

  • Remove the tag key label from the project:

    kubectl label project PROJECT_NAME \
        --kubeconfig ${KUBECONFIG} \
        --namespace platform \
        tag.resourcemanager.gdc.goog/TAG_KEY_NAME-
    

    Replace the following:

    • PROJECT_NAME: the name of the project.
    • TAG_KEY_NAME: the name of the tag key to remove from the project.

    The output is similar to the following:

    project.resourcemanager.gdc.goog/my-project unlabeled
    

What's next