Tags are powerful metadata that you can associate with resources and include in templates. You can use tags in a variety of management scenarios, including workload placement and resource labeling.

Quick introduction to tags

This section is a simple introduction to tags as they apply to the provided steps. For more in-depth information about tags, see How do I use tags to manage vRealize Automation Cloud Assembly resources and deployments.

  • Capability and constraint tags

    You can use of tags to control deployments based on resource capabilities. For example, as a cloud administrator you want the iteratively developed cloud templates to deploy to a development-specific resource pool and the production worthy templates to deploy to a different resource pool.

    • Capability tags are added to resources, defining their capabilities.
    • Constraint tags are used in cloud templates, defining what resources you want the deployed resources to consume.
  • Label tags

    To manage resources, you can add tags as object labels or descriptions. The management possibilities include better resources searching results, differentiating between similar objects, annotating objects with custom information, providing information to third-party systems, creating security grouping membership criteria, ensuring consistency across linked SDDC domains.

Before you begin

Using tags to manage Workload placement

This simple example uses development and production environment tags to demonstrate how to use capability and constraint tags. First, you add capability tags on vCenter Server resource pool compute resources, and then you include the tags in the cloud template. The cloud template example demonstrates how to use inputs to let the deploying user select whether to deploy it to a development or to a production resource pool.

For an example of how to use the same tags to define placement in a multi-cloud environment, see Tutorial: Setting up and testing multi-cloud infrastructure and deployments in vRealize Automation Cloud Assembly.

  1. Add capability tags to resource pools.
    1. Select Infrastructure > Resources > Compute.
    2. Open the cloud zone and click Compute.Screenshot of the cloud zone Compute tab showing resource pools without tags.
    3. Locate and click the resource pool that you want to deploy development workloads to.

      This tutorial uses the following sample values. Remember that these values are only examples. Your values will be specific to your environment.

      Sample resource pool Sample tag
      wid01-clu01 / Development env:dev
      wid01-clu01 / Production env:prod
    4. Add the tag env.dev and click Save.
      Screenshot of the dialog box that you use to add a tag. It includes the sample value env:dev.
    5. Repeat the process for the resource pool that you want to deploy production workloads to and add the env:prod tag.
  2. Verify that the capability tags were added to the resource pools in your cloud zone.
    1. Select Infrastructure > Configure > Cloud Zones.
    2. Open the cloud zone associated with the project and click Compute.

      In this example, the cloud zone is vCenter Account Cloud Zone and the tags were added to the two resource pools, wid01-clu01 / Development and wid01-clu01 / Production.

      Screenshot of the vCenter Server cloud zone where one cloud zone has the tag env:dev and another has env:prod.
  3. Add constraint tags to the cloud template.

    Constraint tags are used to limit where the template is deployed.

    1. Select Design > Cloud Templates and then open your template.

      In this tutorial, the template name is Development Template.

    2. Review the YAML for the template in the Code pane.

      This YAML is the starting point for this tutorial.

      formatVersion: 1
      inputs: {}
      resources:
        Cloud_vSphere_Machine_1:
          type: Cloud.vSphere.Machine
          properties:
            image: centos
            flavor: medium
            networks:
              - network: '${resource.Cloud_NSX_Network_1.id}'
            attachedDisks:
              - source: '${resource.Cloud_vSphere_Disk_1.id}'
        Cloud_vSphere_Disk_1:
          type: Cloud.vSphere.Disk
          properties:
            capacityGb: 5
        Cloud_NSX_Network_1:
          type: Cloud.NSX.Network
          properties:
            networkType: existing
      
    3. Add the constraint tag to the Cloud_vSphere_Machine_1 resource using ${input.placement} as a variable.
      resources:
        Cloud_vSphere_Machine_1:
          type: Cloud.vSphere.Machine
          properties:
            image: centos
            flavor: medium
            constraints: 
              - tag: '${input.placement}'
            networks:
              - network: '${resource.Cloud_NSX_Network_1.id}'
            attachedDisks:
              - source: '${resource.Cloud_vSphere_Disk_1.id}'
    4. Define the placement variable in the Inputs section.
      inputs:
        placement:
          type: string
          enum:
            - env:dev
            - env:prod
          default: env:dev
          title: Select Placement for Deployment
          description: Target Environment
    5. Verify that the final YAML looks similar to the following example.
      formatVersion: 1
      inputs:
        placement:
          type: string
          enum:
            - 'env:dev'
            - 'env:prod'
          default: 'env:dev'
          title: Select Placement for Deployment
          description: Target Environment
      resources:
        Cloud_vSphere_Machine_1:
          type: Cloud.vSphere.Machine
          properties:
            image: centos
            flavor: small
            constraints:
              - tag: '${input.placement}'
            networks:
              - network: '${resource.Cloud_NSX_Network_1.id}'
            attachedDisks:
              - source: '${resource.Cloud_vSphere_Disk_1.id}'
        Cloud_vSphere_Disk_1:
          type: Cloud.vSphere.Disk
          properties:
            capacityGb: 5
        Cloud_NSX_Network_1:
          type: Cloud.NSX.Network
          properties:
            networkType: existing
    6. To try out the tag variable against the available resources, click Test and then select env:dev.
      Screenshot of the testing dialog box with the Select Placement for Deployment input and the value env:dev.

      Repeat the test using env:prod. When both tests are successful, confirm that the template works by deploying it.

  4. Deploy the template to test the workload placement.
    1. In the cloud template designer, click Deploy.
    2. Enter Deployment Tag Dev as the Deployment Name and click Next.
    3. Select env:dev in the Select Placement for Deployment drop-down menu and click Deploy.
  5. Verify that the template deployed the resources to the selected resource pool.
    1. On the Deployments tab, locate the Deployment Tag Dev deployment.
    2. Open the deployment details and click Topology.
    3. Click the vSphere machine and expand the machine information in the right pane.
    4. In the General section, locate Compute host and verify that the value matches the resource pool that matches your env:dev tag.

      In this example, the value is wid01-clu01 / Development, illustrating that the workload was deployed to correct resource pool based on the selected constraint tag.


      Screenshot of the deployment topology page with the vSphere machine selected a box around Compute host in the right pane.
    5. Repeat the deployment process, this time select env:prod.

Adding tags as labels that you can use in vCenter Server and NSX-T

You can add tags to deployments that you can then use to manage resources.

In this example, you add tags to identify the MySQL machine and network. You also add a tag to identify the web network. Due to how tags work on existing networks compared to on-demand networks, you have two choices.

  • If you use the existing network profile that you used in the previous section, the NGINX:web tag is not added to existing objects in NSX-T. So you can ignore the verification steps regarding this tag in NSX-T.
  • If you create an on-demand network profile, you can update the network in the YAML to use the routed/on-demand network. The on-demand network is used in this example so that we can demonstrate the NGINX:web tag on the new object in NSX-T.

The following YAML is from the previous example except that it uses a routed on-demand networkType. It includes the constraint tags.

This tutorial uses the following sample values. Remember that these values are only examples. Your values will be specific to your environment.

formatVersion: 1
inputs:
  placement:
    type: string
    enum:
      - 'env:dev'
      - 'env:prod'
    default: 'env:dev'
    title: Select Placement for Deployment
    description: Target Environment
resources:
  Cloud_vSphere_Machine_1:
    type: Cloud.vSphere.Machine
    properties:
      image: centos
      flavor: small
      constraints:
        - tag: '${input.placement}'
      networks:
        - network: '${resource.Cloud_NSX_Network_1.id}'
      attachedDisks:
        - source: '${resource.Cloud_vSphere_Disk_1.id}'
  Cloud_vSphere_Disk_1:
    type: Cloud.vSphere.Disk
    properties:
      capacityGb: 5
  Cloud_NSX_Network_1:
    type: Cloud.NSX.Network
    properties:
      networkType: routed
      constraints:
        - tag: 'net:od'
      
  1. Select Design > Cloud Templates and then open your template.
  2. In the Cloud_vSphere_Machine_ properties, add the following tag.
            tags: 
            - key: db
              value: mysql
        
  3. Add VM NIC tags.
            tags: 
            - key: db
              value: mysql
  4. Add NSX logical switch/segment tags.
            tags: 
            - key: NGINX
              value: web
  5. Verify that the YAML looks similar to the following example.
    formatVersion: 1
    inputs:
      placement:
        type: string
        enum:
          - 'env:dev'
          - 'env:prod'
        default: 'env:dev'
        title: Select Placement for Deployment
        description: Target Environment
    resources:
      Cloud_vSphere_Machine_1:
        type: Cloud.vSphere.Machine
        properties:
          image: centos
          flavor: small
          constraints:
            - tag: '${input.placement}'
          tags: 
            - key: db
              value: mysql
          networks:
            - network: '${resource.Cloud_NSX_Network_1.id}'
              tags: 
                - key: db
                  value: mysql
          attachedDisks:
            - source: '${resource.Cloud_vSphere_Disk_1.id}'
      Cloud_vSphere_Disk_1:
        type: Cloud.vSphere.Disk
        properties:
          capacityGb: 5
      Cloud_NSX_Network_1:
        type: Cloud.NSX.Network
        properties:
          networkType: routed
          constraints:
            - tag: 'net:od'
          tags: 
            - key: NGINX
              value: web
  6. Deploy the template.

    This example uses the name Development template w tags.

  7. To verify the tags in the deployment, open the deployment and click the Topology tab.
    1. Click the machine in the topology.
    2. Expand the General section for the machine and locate the Tags label.

      The tag value is db:mysql.

    3. Expend the Network section and locate the network Tags column.

      The tag value is db:mysql.


      Screenshot of the deployment topology tab with the machine selected and the tags highlighted in the right pane.
    4. Click the network in the topology and expand the General section to locate the Tag label.

      The tag value is NGINX:web.


      Screenshot of the deployment topology tab with the network selected and the tag highlighted in the right pane.
  8. To verify the tags in vCenter Server, log in to the vCenter Server instance where this workload was deployed.
    1. Locate the virtual machine and locate the Tags pane.
      Screenshot of the virtual machine in vCenter Server with the Tags pane highlighted.
  9. To verify the tags in NSX-T, log in to the NSX-T instance where this network is configured.
    1. Click Policy in the upper right corner.
    2. To locate the db:mysql tag associated with the NIC, search for mysql.
    3. Click Logical Ports and locate the deployed vSphere machine.
    4. Click the number in the Tags column.

      The Scope and Tag are db and mysql respectively.


      Screenshot of the logical port for the virtual machine with tags highlighted.
    5. To locate the NGINX:web tag associated with segment, search for the network.

      In this example, the network name is Cloud_NSX_Network_1-mcm1292-163799928607.

    6. Locate the Segments row and click the number in the tags column.

      The Scope and Tag are NGINX and web respectively.


      Screenshot of the network segment with tags highlighted.