Migrations to Astro
Project description
Astronomer Starship
A suite of Apache Airflow utilities containing Plugins and Operators from Astronomer. The purpose of these utilities is to better assist customers migrating Variables, Connections, and Environment Variables to Astronomer hosted Airflow environments from MWAA, GCC, and OSS environments, as well as Astronomer Software and Nebula instances.
Depending on the source environment, either the Webserver Plugin or the AstroMigrationOperator should be used for migrating these elements.
Note: In order to use the Starship utilities, the source Airflow environment must be running Airflow 2.x
Choosing the right package
The AstroMigrationOperator should be used if migrating from a Google Cloud Composer 1 (with Airflow 2.x) or MWAA v2.0.2 environment. These environments do not support webserver plugins and will require using the AstroMigrationOperator to migrate Connections, Variables, and Environment Variables.
The Starship Plugin should be used for migrating from all other environments including Google Cloud Composer 2, MWAA v2.2.2, OSS, and Astronomer Software/Nebula instances.
Installation
Installation for both the plugin and operator are the same
Install and update using pip:
pip install astronomer-starship
Usage
Add the following line to your requirements.txt in your source environment:
astronomer-starship
Add the following DAG to your source environment:
from airflow import DAG
from astronomer.starship.operators import AstroMigrationOperator
from datetime import datetime
with DAG(
dag_id="astronomer_migration_dag",
start_date=datetime(2020, 8, 15),
schedule_interval=None,
) as dag:
AstroMigrationOperator(
task_id="export_meta",
deployment_url='{{ dag_run.conf["deployment_url"] }}',
token='{{ dag_run.conf["astro_token"] }}',
)
Deploy this DAG to your source Airflow environment, configured as described in the Configuration section below
Once the DAG is available in the Airflow UI, click the “Trigger DAG” button, then click “Trigger DAG w/ config”, and input the following in the configuration dictionary:
astro_token: To retrieve an Astronomer token, navigate to cloud.astronomer.io/token and log in using your Astronomer credentials
deployment_url: To retrieve a deployment URL - navigate to the Astronomer Airlow deployment that you’d like to migrate to in the Astronomer UI, click Open Airflow and copy the page URL (excluding /home on the end of the URL)
For example, if your deployment URL is https://astronomer.astronomer.run/abcdt4ry/home, you’ll use https://astronomer.astronomer.run/abcdt4ry
The config dictionary used when triggering the DAG should be formatted as:
{
"deployment_url": "your-deployment-url",
"astro_token": "your-astro-token"
}
Once the DAG successfully runs, your connections, variables, and environment variables should all be migrated to Astronomer
Configuration
The AstroMigrationOperator can be configured as follows:
variables_exclude_list: List the individual Airflow Variables which you do not want to be migrated. Any Variables not listed will be migrated to the desination Airflow deployment.
connection_exclude_list: List the individual Airflow Connections which you do not want to be migrated. Any Variables not listed will be migrated to the desination Airflow deployment.
env_include_list: List the individual Environment Variables which you do want to be migrated. Only the Environment Variables listed will be migrated to the desination Airflow deployment. None are migrated by default.
AstroMigrationOperator(
task_id="export_meta",
deployment_url='{{ dag_run.conf["deployment_url"] }}',
token='{{ dag_run.conf["astro_token"] }}',
variables_exclude_list=["some_var_1"],
connection_exclude_list=["some_conn_1"],
env_include_list=["FOO", "BAR"],
)
Running Telescope Report
To run the Telescope Report, to get a snapshot of your source Airflow Instance
Hover over the Astronomer menu in the Airflow UI and select Run Report 🔭 Telescope
Enter your Organization’s Name
(Optionally) Enter a pre-signed URL if you were supplied one, or request one from your Astronomer representative
Hit “Send/Download Report”
If you didn’t use a pre-signed URL, send the report to your Astronomer Representative.
More information about this report can be gathered from https://github.com/astronomer/telescope#what-is-it
Astronomer Starship Plugin
Starship is an Airflow Plugin meant to assist customers migrating Variables, Connections, and Environment Variables from a source Airflow to an Astro Airflow.
Initial Setup
Add the following line to your requirements.txt in your source environment:
astronomer-starship
Once your source environment has astronomer-starship installed, you will see a new Astronomer menu. Hover over that menu and select the Migration Tool 🚀 option
After opening the plugin page, you will need to authenticate to Astronomer. To do this, please:
Click the Get Token button
If you are prompted to sign-in to cloud.astronomer.io please do so
Copy the access token that appears in the new tab
Paste the access token into the Authentication Token field
Click the Sign In button
After authenticating to Astronomer, you will need to select the deployment that you are sending metadata to. To do this, select a deployment from the Target Deployment dropdown and click the Select button
Migrating Airflow Connections
To migrate connections from your source Airflow meta-database:
1.. Click on the Connections tab: 2. In the table displaying the connections that can be migrated, click the Migrate button for each connection that needs to be sent to the Target Deployment:
Once the Migrate button is clicked, the connection will be sent to the Target Deployment and will show as Migrated ✅ in the plugin UI:
Migrating Airflow Variables
To migrate variables from your source Airflow meta-database:
Click on the Variables tab:
In the table displaying the variables that can be migrated, click the Migrate button for each variable that needs to be sent to the Target Deployment
Once the Migrate button is clicked, the variable will be sent to the Target Deployment and will show as Migrated ✅ in the plugin UI
Migrating Airflow Pools
To migrate pools from your source Airflow meta-database:
Click on the Pools tab:
In the table displaying the pools that can be migrated, click the Migrate button for each pool that needs to be sent to the Target Deployment
Once the Migrate button is clicked, the pool will be created in the Target Deployment and will show as Migrated ✅ in the plugin UI:
Migrating Environment Variables
To migrate environment variables from your source Airflow:
Click on the Environment Variables tab:
In the table displaying the environment variables that can be migrated, ensure the checkbox is ticked for each environment variable that needs to be sent to the Target Deployment
Once all of the desired environment variable checkboxes have been selected, click the Migrate button in the table header
After clicking the Migrate button in the table header, each selected environment variable will be sent to the Target Deployment and the ticked checkbox will display Migrated ✅
Utilizing DAGs Cutover Tab
The DAGs Cutover Tab can be utilized to pause DAGs in the source environment and unpause DAGs in the target environment (as long as the DAG id in both the source and target environment match). To do so, please:
Click on the DAGs Cutover tab:
In the table displaying the DAGs present in both the source and target environments, click the Pause ⏸️ icon under Local
In the table displaying the DAGs present in both the source and target environments, click the Start ▶️ icon under Remote
After completing this process, you will see the DAG is paused in the Local environment (a Start ▶️ Icon) and is un-paused in the Remote environment (a Pause ⏸️ icon)
FAQ
If you have an error installing Starship via pip and see a message like
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed
, add the dependencies that are listed in the error to yourpip install
orrequirements.txt
, e.g.
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
rich 10.9.0 requires typing-extensions<4.0.0,>=3.7.4; python_version < "3.8", but you have typing-extensions 4.6.3 which is incompatible.
pip install astronomer-starship rich==10.9.0
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for astronomer_starship-1.0.5.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1cc87f65d126e582d5af446de8a86511d08ae17e61f51b808942d02804f3bb87 |
|
MD5 | e23e6027cd43a576a44206e4f6dc83fc |
|
BLAKE2b-256 | b2089a62716dd3631c7a561f6f590368f0845c73ba9a761c2a413739e0b132e2 |
Hashes for astronomer_starship-1.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce1141d51353383c406f44f34cbf964de0d84d817c74c9f2b40f8ce37c0cf458 |
|
MD5 | 6008be70761f5c33e1b3be3e49e65dbf |
|
BLAKE2b-256 | 5dc567aa7ffc4cbd9e5f594ab5d1c0e5ce26aed61f52a00b86fbb42c5a3f7754 |