datastax / zdm-proxy-automation

An Ansible-based automation suite to deploy and manage the Zero Downtime Migration Proxy
https://docs.datastax.com/en/astra-serverless/docs/migrate/introduction.html
Apache License 2.0
62 stars 4 forks source link

ZDM Proxy Automation

An automation suite to deploy and manage the Zero Downtime Migration Proxy

Important note

This automation is being widely used by DataStax as part of the Zero Downtime Migration suite. The Ansible automation and the ZDM Utility have been used in numerous migrations of large-scale production environments and we are actively evolving them. They are also fully documented in the official ZDM Documentation.

All the automation material in this repository is licensed under the Apache Licence v2.0. Feel free to clone this repository and use this material as it is, as well as fork it and adapt it as appropriate if your environment or deployment strategy preferences are different.

We endeavor to expand and maintain this automation to ensure it works as expected, and we welcome suggestions from the community. However, we cannot always guarantee that we will implement feature requests or review and merge community contributions in a defined timeframe.

Overview

The Zero Downtime Migration Proxy (ZDM proxy) is an open-source component written in Go and designed to seamlessly handle the real-time client application activity while the client application's data is being migrated between CQL clusters (which we will refer to as Origin and Target). For comprehensive documentation on how to use the ZDM Proxy to perform a zero-downtime migration, please see the official ZDM Documentation.

This automation suite provides several components to make it easier to provision, deploy and manage a cluster of ZDM Proxy instances in development, test and production environments.

The components in this suite are:

Ansible automation

The Ansible automation is located in the ansible directory and contains the following playbooks:

This automation requires the infrastructure for the ZDM deployment to have already been provisioned. For its infrastructure requirements, please see this documentation page.

For detailed documentation on how to use this automation, please refer to this section of the official ZDM documentation.

Setting up the Ansible Control Host

The Ansible automation must be run from a machine on which Ansible has been installed, known as the Ansible Control Host. This machine must have SSH access to all hosts on which the ZDM Proxy instances will be deployed.

Setup using the ZDM Utility

While it is perfectly possible to set up the Ansible Control Host manually, the ZDM Utility provides an easy and interactive way to spin it up as a Docker container. This utility can be downloaded from here as a pre-built Go executable for a variety of platforms.

For detailed information about using the ZDM Utility, please see this documentation page.

As explained in the prerequisites, you will need to install Docker and enable your regular user to run the docker command without super user permissions.

Alternative manual setup

Using the ZDM Utility is convenient but not necessary. If you choose not to use it, you can install and configure the Ansible Control Host manually. This may be useful if you cannot or do not want to use Docker on the machine from which you will run the playbooks.

To do so, if your machine runs Ubuntu you can use the script setup_ansible_control_host.sh located in orchestration-scripts. Note: you will need to uncomment and populate some required variables at the top of the script before running it. For different Linux distributions, feel free to adapt this script accordingly.

Terraform automation

The Terraform automation contains a set of modules to provision infrastructure and configure the networking for a standard, self-contained ZDM deployment in a dedicated VPC to which your existing VPC can be peered. This automation is currently only available for AWS. Other cloud providers may be supported in the future.

Using this Terraform automation is completely optional: the infrastructure can be provisioned manually or by any other means, as long as it complies with the requirements documented here.

The following diagram shows the infrastructure and networking layout provisioned in AWS using these modules. Note that Target can be any cluster in any infrastructure, as long as it is reachable by the ZDM Proxy instances on the port on which the cluster listens for client connections.

AWS infrastructure and networking layout provisioned by Terraform

In the terraform/aws directory there are the following modules:

To launch the Terraform automation, you can use one of the two bash scripts provided in the directory orchestration-scripts:

Both scripts require some configuration, in the form of required and optional variables at the top of each script. You will need to uncomment and populate these variables as appropriate. If you are using the option with peering, the peering connection will be created automatically, but you may still need to make changes to the security groups of your cluster and / or client application instances to allow communication with the ZDM instances, depending on your specific configuration.

An optional custom suffix can be specified, e.g. to distinguish infrastructure for different ZDM deployments within the same AWS account. In this case, the suffix is appended to the name of each resource (separated by a dash), and an Owner AWS tag set to the suffix value is assigned to each resource. This allows to easily see all infrastructure for a certain deployment by filtering by its Owner tag.

When you execute the script, the Terraform output will be displayed and at the end you will see:

In addition, the Terraform automation creates the following two files:

Docker Compose for Local Development

The Compose file docker_compose.yml in the base directory of this repository and the scripts in the compose directory can be used to spin up a local ZDM deployment using containers. This can be convenient for exploration and local testing, including testing of the Ansible automation.

The ZDM deployment thus created includes:

As prerequisites, ensure that:

You will be using the docker-compose command, which in some installations may be available as docker compose.

To create this deployment, simply run:

docker-compose up

For more details on Docker Compose, please refer to the official documentation.

To issue CQL requests through the proxy, launch cqlsh on the client container (zdm-proxy-automation_client_1) connecting to a proxy instance:

docker exec -it zdm-proxy-automation_client_1 cqlsh zdm-proxy-automation_proxy_1

From this shell, you can execute read and write CQL requests that will be handled by the proxy and routed appropriately.