A GCP Compute Engine controlled example staff (MIG) helps any VM configuration that you want, and it is helping organize the VMs for you. As an example, when a VM in a MIG abruptly stops working, the MIG recreates that VM in keeping with the configuration that you just set. You’ll additionally arrange an application-based well being test to ensure that your utility responds as anticipated on every VM.
Along with that, MIGs additionally lets you deploy complicated stateful packages, similar to databases (Cassandra, ElasticSearch) or information processing packages (Kafka, Flink), the place preservation of person VM state (for instance, a database shard, or app configuration) is necessary.
In case you are simply beginning to paintings with GCP and need to deploy a stateful utility, then it’s extremely beneficial to make use of a stateful MIG configuration. A stateful MIG lets you keep the original state of every example (together with example title, connected continual disks, IP addresses – to be had in Preview, and metadata) on VM restart, sport, auto-healing, or replace. You’ll be told extra about Stateful MIGs via studying the medical doctors.
The purpose of this weblog submit is to assist those that have already got an present stateful utility working on standalone (unmanaged) Compute Engine circumstances and who need to mechanically migrate them to a stateful MIG the usage of a Python script. The script code and detailed directions for its use and set up may also be discovered right here. In case you need to do that complete procedure manually, you’ll pass in the course of the Migrate an present workload to a stateful controlled example staff educational.
Let’s dive into the good judgment of the script and notice how it may be performed.
Script necessities
Earlier than working the script, make sure that your present circumstances meet the next standards:
-
All supply circumstances will have to have the similar example configuration (for instance, gadget sort). Keep in mind that all circumstances in a MIG are created in keeping with the similar example template. The script creates a template for you in keeping with considered one of your present circumstances.
-
Your boot disks must be stateless. Should you will have to keep state in your boot disks, then you’ll nonetheless create a stateful MIG, however you can’t replace running programs or tool via rolling out boot symbol updates.
-
The script will forestall your supply VM circumstances. The script leaves all supply VMs stopped with their disks intact, for simple reverting if the MIG does not paintings as anticipated. This leads to further prices, for the next causes:
-
The script does not detach or delete the unique disks.
-
The script creates photographs from present disks.
Script steps
-
Forestall all circumstances
-
If wanted, create a boot disk symbol
-
Create an example template in keeping with the houses of a selected example, whilst ignoring connected information disks.
-
Create an empty MIG.
-
For every example within the unique staff, carry out the next steps:
-
Clone all example disks excluding the boot disk.
-
Create an example within the MIG in keeping with the example template, and come with the cloned disks from the supply example.
-
Print instructions for cleansing up the supply circumstances upon getting verified that the stateful MIG serves your wishes.
In case you are in a position to make use of the script, apply the hyperlink for set up and execution.
Utilization instance
Let’s now believe some example configuration and display how the script proceeds. Assume now we have 3 standalone circumstances with names “alpha”, “beta”, and “gamma” within the us-central1-a zone and we need to migrate them to a MIG with the title “greek”.
Example “alpha” has two further disks: “alpha-disk-1” and “alpha-disk-2”, example “beta” has one further disk “beta-disk-1”, and “gamma” has 0 further disks. On the similar time we wish to create a disk symbol for the boot symbol.
Run the next command:
$ python3 migrate_script.py -s alpha beta gamma -z us-central1-a -m greek --image_for_boot_disk
Let’s have a look at the output step-by-step:
-
The entire circumstances are stopped on the very starting.