Skip to main content
Labeling at scale in Google Cloud Migration Center
  1. Posts/

Labeling at scale in Google Cloud Migration Center

·652 words·4 mins
Christoph Petersen
Author
Christoph Petersen

Google Cloud Migration Center is a great way to understand the total cost of ownership (TCO) for a migration to Google Cloud by running automatic assessments or uploading information about an estate using the output of tools such as RVTools.

The power of groups
#

IT environments can be quite complex and may have grown over the years. Line of businesses may have different requirements in terms of the compute platform or locality of their workloads. In order to accurately model these requirements, Migration Center uses Groups to logically group discovered assets.

Groups can be built by using common attributes associated will all assets such as its name, operating system family and others. Another way is to assign labels (key/value pairs using the same semantics as resource labels) to assets and use these as another attribute for grouping.

Adding labels (at scale)
#

Adding labels to assets through Google Cloud Console works well as long as the number of assets is manageable. But for environments with 100s if not 1000s of assets, this becomes untenable.

Migration Center provides an API that could be leveraged to programmatically add labels to the assets in question. That programming logic must be implemented first though and more often than not you need to add labels in a time crunch quickly.

Luckily there is a neat way to add labels at scale by using the data import functionality with manually populated files.

Create asset sheet
#

Start by populating an asset sheet (template can be found in the documentation). While the assets you want to add labels to are already imported, Migration Center requires a list of assets to be provided for the data import. Essentially, this file will just hold the identifiers of the machines, that we want to add labels for but no further metadata.

Important: When associating labels with existing assets that were imported with automatic discoveries or RVTools, the identifier needs to represent the original data source to allow Migration Center to correlate these resources:

  • Discovery Client: Use the asset export feature to retrieve a list of all assets; use VM UUID as identifier
  • RVTools: Use VM UUID found in vInfo as identifier

The following snippet creates the asset sheet and populates it with a few sample entries:

echo "MachineId,MachineName,TotalDiskAllocatedGiB,TotalDiskUsedGiB,AllocatedProcessorCoreCount,MemoryGiB,OsName,IsPhysical" > assets.csv
echo "6160266098198287760,,,,,,," >> assets.csv
echo "8064767013718693264,,,,,,," >> assets.csv

Create labels sheet
#

The second step is to create a sheet that holds the key/value association for the assets. This file will hold the asset identifier the label name and its value. Note: the label key name and value must adhere to the semantics for resource labels!

Multiple labels can be added by adding multiple rows for the same asset. If an asset does not need to have a label assigned it can be omitted from this file.

The following snippet assigns a region label to the assets to show the concept:

echo "MachineId,Key,Value" >> labels.csv
echo "6160266098198287760,region,us-central1" >> labels.csv
echo "8064767013718693264,region,europe-west4" >> labels.csv

Import data
#

Open Cloud Console and navigate to Migration Center. From the menu select Data Import. Select + ADD DATA and Upload files:

Import jobs screen

Provide a name for the import job, select Manually populated template CSV as file format and upload the two files crated in the previous steps:

Upload files screen

Select UPLOAD FILES and once the upload and validation has completed continue by clicking IMPORT DATA:

Import data screen

Depending on the number of assets that were included in the files, processing can take a few moments to complete. Once that backend process has finished the previously discovered or added assets will now show labels and it is visible that two data sources contributed to the information known to Migration Center:

Assets screen with labels set

Summary
#

Adding labels privides an easy and extensible way to add additional metadata to assets at scale. This helps to organize assets into logical groups and will make it easier to manage large environments with 100s or 1000s of assets.

Related

Protect disk snapshots against accidental deletion or malicious tampering

·1421 words·7 mins
It could happen. Total mahem. An administrative pricipal for a project was accidentally leaked. An attacker has taken you projects hostage. You need to recover and fast. Restoring project access is the least of your worries your concern is to restore services. Luckily you have all workloads protected with snapshots! All deleted by the attacker! This is an exaggerated and hypothetical scenario but I have seen similar things happening. In this article I’m exploring an approach to protect against such a scenario.

Enabling cross-project Microsoft Managed Active Directory integration for Cloud SQL for SQL Server

·1203 words·6 mins
One of the most requested features from customers that deploy Cloud SQL for SQL Server (Cloud SQL) has been Active Directory integration which was released last year. Since then Google Cloud has added cross-project capability which allows you to connect your Cloud SQL instance into a project that is different than the one hosting Managed Microsoft AD (Managed AD).

IAP command chaining

·584 words·3 mins
Identity-Aware Proxy (IAP) is a powerful tool in the tool chain of Google Cloud administrators and users. It can be used to control access to cloud-based and on-premises applications and VMs running on Google Cloud.