Tagging Clusters

Page last updated:

This topic explains how to tag new and existing clusters using the PKS CLI.

Overview

IaaSes provide the ability for customers to “tag” VMs, databases, and other resources with custom labels and metadata values. Apply one or more tags to your clusters to simplify organizing, managing, searching for, and filtering resources within your IaaS-provided management console and other tools:

  • If your Enterprise PKS deployment is on Azure or vSphere, including vSphere with NSX-T, you can use the PKS CLI to tag clusters by following the steps in Tag Your Clusters as They Are Created below.

  • If your Enterprise PKS deployment is on AWS or GCP, you can tag your clusters using your IaaS-provided management console.

Note: Enterprise PKS Cluster tagging requires Ops Manager v2.8.0 or later.

Tag Your Clusters as They Are Created

To apply tags to your cluster’s VMs, include the --tags parameter in your pks create-cluster command line, and specify the desired tags as a comma-delimited list of key:value pairs.

pks create-cluster CLUSTER-NAME --tags "TAGS"

Where:

  • CLUSTER-NAME is the name of the cluster to create.
  • TAGS is a comma-delimited list of key:value pairs to apply to the cluster.

For example:

$ pks create-cluster my-cluster --tags "status:billable"
$ pks create-cluster my-cluster --tags "status:non-billable,region:northwest"
$ pks create-cluster my-cluster --tags "client:example.com, costcenter:pettycash"

Tag Your Existing Clusters

To apply tags to your existing cluster’s VMs, run the pks update-cluster command line, and specify the --tags parameter and a comma-delimited list of key:value pairs of the tags to apply to the cluster.

pks update-cluster CLUSTER-NAME --tags "TAGS"

Where:

  • CLUSTER-NAME is the name of the cluster to tag.
  • TAGS is a comma-delimited list of key:value pairs.

For example:

$ pks update-cluster my-cluster --tags "client:tinymegacorp"
$ pks update-cluster my-cluster --tags "client:example.com,costcenter:pettycash"
$ pks update-cluster my-cluster --tags "status:non-billable, region:northwest"

Modify Cluster Tags

You can also use pks update-cluster to modify your cluster’s existing tags. When you modify cluster tags you completely replace all of the cluster’s existing tags with the specified tags.

Note: On Azure, pks update-cluster cannot remove tags from your IaaS. For more information, see Azure-Specific Tagging Limitations below.

Modify Your Existing Tags

To modify your cluster’s existing tags do the following:

  1. Retrieve the cluster’s existing tags list string by running pks cluster. For information on pks cluster Review Your Tags below.

  2. Modify the tags list string by doing one of the following:

    • To add a new tag, append it to existing tags list string.
    • To modify an existing tag, modify it within the tags list string.
    • To remove an existing tag, delete it from within the tags list string.
  3. Run the following command:

    pks update-cluster CLUSTER-NAME --tags "TAGS"
    

    Where TAGS is a comma-delimited list of revised key:value pairs.

Remove All Tags From Your Cluster

To remove all of your cluster’s existing tags do the following:

  1. Run the following pks update-cluster --tags on your command line:

    pks update-cluster CLUSTER-NAME --tags ""
    

    Where CLUSTER-NAME is the cluster to remove tags from.

Review Your Tags

To review the tags applied to a cluster, run pks cluster.

For example:

$ pks cluster my-cluster
Name:                     my-cluster
Plan Name:                large
UUID:                     01a234bc-d56e-7f89-01a2-3b4cde5f6789
Last Action:              CREATE
Last Action State:        succeeded
Last Action Description:  Instance provisioning completed
Kubernetes Master Host:   my-cluster.example.com
Kubernetes Master Port:   8443
Worker Instances:         3
Kubernetes Master IP(s):  192.168.20.7
Tags:                     client:tinymegacorp,costcenter:pettycash

The pks cluster function returns only the custom tags you’ve applied to the cluster using the PKS CLI. To display all of the tags applied to your cluster VMs use your IaaS-provided management console.

Note: Do not use the IaaS-provided management console to modify your custom tags. Custom tag alterations you’ve applied via the management console will be overwritten when you next run pks update-cluster.

Tagging Rules

The tagging you apply must adhere to the following rules:

  • Tag names and values should not include either ", : or ,.
  • Surrounding double quotes are required if there are one or more spaces in your tag list, such as a space after a comma delimiter.
  • Tag names and values must adhere to the tagging rules of the IaaS hosting your Enterprise PKS environment.


For information about IaaS-specific tagging rules see the following:

Tagging Limitations

Cluster tagging has the following limitations:

Tags Reserved for BOSH

The BOSH layer applies 10 system-level metadata tags to each cluster, including deployment, director, id, index, instance_group, job, and name. These reserved tags impose the following limitations:

  • The maximum number of custom tags you can apply to a cluster is 10 less than the maximum number of tags supported by your IaaS.

    • For example: Azure limits tagging to a maximum of 50 tags per entity. Therefore, if your Enterprise PKS environment is hosted on Azure, apply fewer than 40 custom tags to your clusters.
  • You cannot set or change BOSH system-level tags using the PKS CLI. If you use the PKS CLI to create tags with those reserved names, they are ignored.

    • When you try to change system-level tags with the PKS CLI, the output of pks cluster shows the tag values passed into the create-cluster or update-cluster command, but BOSH overrides and ignores these settings.

Azure-Specific Tagging Limitations

The following are the known Azure-specific IaaS tagging limitations:

  • pks update-cluster cannot remove tags from your Azure clusters. This limitation is due to an issue in the Azure CPI for BOSH which is used by pks cli for Azure IaaS tagging.
    • To remove an IaaS tag from an Azure cluster do the following:
      1. Perform the removal steps described in Modify Existing Tags above.
      2. Remove unwanted tags through the Azure portal.

For information about additional Azure-specific tagging limitations see Use tags to organize your Azure resources in the Azure documentation.

vSphere-Specific Tagging Limitations

The following are the known vSphere-specific IaaS tagging limitations:

  • pks update-cluster applies tagging to vSphere entities as vSphere Custom Attributes. This limitation is due to an issue in the vSphere CPI which is used by pks cli for vSphere IaaS tagging.
    • vSphere Custom Attribute tagging is applied to VMs only. Disks and other resources are not tagged.
    • A vSphere Custom Attribute applied to a single VM is also visible on all other VMs, but as an empty property.

For information about additional vSphere-specific tagging limitations see vSphere Tags and Attributes in the vSphere documentation.


Please send any feedback you have to pks-feedback@pivotal.io.