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 Automation Assembler 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
- Review the resources and cloud template defined in Tutorial: Setting up and testing vSphere infrastructure and deployments in Automation Assembler. The sample values used in that tutorial are used here.
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 Automation Assembler.
- Add capability tags to resource pools.
- Select .
- Open the cloud zone and click Compute.
- 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
- Add the tag env.dev and click Save.
- Repeat the process for the resource pool that you want to deploy production workloads to and add the env:prod tag.
- Verify that the capability tags were added to the resource pools in your cloud zone.
- Select .
- 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.
- Add constraint tags to the cloud template.
Constraint tags are used to limit where the template is deployed.
- Select
In this tutorial, the template name is Development Template.
and then open your template. - 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
- 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}'
- 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
- 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
- To try out the tag variable against the available resources, click Test and then select env:dev.
Repeat the test using env:prod. When both tests are successful, confirm that the template works by deploying it.
- Select
- Deploy the template to test the workload placement.
- In the cloud template designer, click Deploy.
- Enter Deployment Tag Dev as the Deployment Name and click Next.
- Select env:dev in the Select Placement for Deployment drop-down menu and click Deploy.
- Verify that the template deployed the resources to the selected resource pool.
- Select and locate the Deployment Tag Dev deployment.
- Open the deployment details and click Topology.
- Click the vSphere machine and expand the machine information in the right pane.
- 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. - 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'
- Select and then open your template.
- In the Cloud_vSphere_Machine_ properties, add the following tag.
tags: - key: db value: mysql
- Add VM NIC tags.
tags: - key: db value: mysql
- Add NSX logical switch/segment tags.
tags: - key: NGINX value: web
- 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
- Deploy the template.
This example uses the name Development template w tags.
- To verify the tags in the deployment, open the deployment and click the Topology tab.
- Click the machine in the topology.
- Expand the General section for the machine and locate the Tags label.
The tag value is
db:mysql
. - Expend the Network section and locate the network Tags column.
The tag value is
db:mysql
. - Click the network in the topology and expand the General section to locate the Tag label.
The tag value is
NGINX:web
.
- To verify the tags in vCenter Server, log in to the vCenter Server instance where this workload was deployed.
- Locate the virtual machine and locate the Tags pane.
- Locate the virtual machine and locate the Tags pane.
- To verify the tags in NSX-T, log in to the NSX-T instance where this network is configured.
The network tags and machine tags are added to NSX-T.
- Click Policy in the upper right corner.
- To locate the
db:mysql
tag associated with the NIC, search for mysql. - Click Logical Ports and locate the deployed vSphere machine.
- Click the number in the Tags column.
The Scope and Tag are
db
andmysql
respectively. - 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.
- Locate the Segments row and click the number in the tags column.
The Scope and Tag are
NGINX
andweb
respectively.