Ritu Singh
It's great to see how Apache Airflow has revolutionized workflow automation, and Google Cloud Composer takes this power to new heights by offering a fully managed platform. If you're a beginner working with the Google Cloud Platform, then this blog will take you through the complete steps to set up a Cloud Composer environment. With the help of this blog, beginners can quickly kickstart their workflow orchestration journey.
So let’s get started and learn about the Prerequisites:
A Google Cloud account
Google Cloud SDK installed on your local machine
Step 1: Creating Your Google Cloud Project
Creating a Google Cloud project is the first essential step to embarking on your journey to set up a gcp Composer environment. This project will serve as the foundation for your Cloud Composer environment and the workflows you'll orchestrate. Here's how you can do it:
Log in to your Google Cloud Console.
Launch your web browser, and go to the >Google Cloud Console website.
Click on the project drop-down and either select an existing project or create a new one.
If you already have a project that you want to use, you can select it from the dropdown at the top of the console.
If you don't have a project or want to create a new one, click on the "Select a project" dropdown and then click "New Project."
Step 2: Enabling the Necessary APIs
In this step, we will enable the required APIs to ensure that our Google Cloud project has access to the services and features needed for setting up and using a Cloud Composer environment. Follow the below steps to enable the necessary APIs:
From the Cloud Console, navigate to "APIs & Services" > "Library."
In the left-hand menu, click on "APIs & Services, and then select "Library."
Search for APIs:
You'll see a search bar in the "Library" section. Use this search bar to look for the APIs that need to be enabled for Cloud Composer:
Cloud Composer API: This API allows you to manage Cloud Composer environments and associated resources.
Cloud Storage API: This API enables you to interact with Cloud Storage buckets where you'll store your DAGs (workflow definitions).
Once you have enabled all of the required APIs, you can proceed to the next steps to configure your Cloud Composer environment.
Step 3: Setting Up a Cloud Storage Bucket
Now we have to set up a Cloud Storage bucket. This bucket will serve as a storage location for your DAGs (workflow definitions) and any other assets you need for your workflows.
Follow the steps to create and configure a Cloud Storage bucket:
Go to the Cloud Storage section in the Cloud Console.
Create a new bucket to store your DAGs (workflows) and other assets.
Remember the bucket name for later use.
Step 4: Creating Your Composer Environment
If you already have a Composer installed on your system, Go to the "Navigation menu," then click "Composer," then click on the name of your composer, then click "ENVIRONMENT CONFIGURATION," and then make a note of the Location, the Zone, the name, and the Service account.
If you don't have an existing Composer, follow the below steps:
Navigate to the "Composer" section in the Cloud Console.
Click "Create Environment."
Provide a name for your environment and choose your preferred region.
Configure the environment by selecting machine types, node counts, and network settings.
Also, set environment variables and options in the Composer environment configuration
Step 5: Accessing the Airflow Web UI
The Airflow web user interface (UI) is your control center for managing, monitoring, and visualizing the execution of your workflows in your Cloud Composer environment. Here's how to access and navigate the Airflow UI:
Once your Composer environment is ready, access the Airflow web UI by clicking on the "Airflow" link within your environment.
This UI allows you to monitor and manage the execution of your workflow.
Step 6: Uploading and Managing DAGs
DAGs (Directed Acyclic Graphs) are the heart of your workflows. Create or upload your DAGs to the Cloud Storage bucket you specified. Composer will automatically detect and schedule these DAGs based on their configurations.
As your workload grows, you can adjust the environment settings to match your needs. Modify node counts, machine types, and other parameters. Fine-tune configurations to ensure optimal performance and resource utilization.
Installing Google Cloud SDK
Installing Google Cloud SDK on Windows:
Visit the Google >Cloud SDK download page in your web browser.
Download the Windows Installer appropriate for your system.
Run the downloaded installer executable.
Follow the installation wizard steps:
Choose the installation location.
Select whether to add Google Cloud SDK to your system's PATH (recommended for easier command-line access).
Customize additional settings if desired.
Once the installation is complete, open a Command Prompt or PowerShell window.
Run the following command to initialize the SDK and authenticate:
Follow the prompts to log in with your Google Cloud account and set your default project.
Installing Google Cloud SDK on macOS and Linux:
Visit the Google Cloud SDK download page in your web browser.
Download the appropriate tarball for macOS or Linux.
Open a terminal window and navigate to the directory where the tarball was downloaded.
Extract the tarball using the following command:
Now, navigate to the extracted directory:
Run the installation script:
Follow the prompts to set up the SDK:
After the installation is complete, run the following command to initialize the SDK and authenticate:
Follow the prompts to log in with your Google Cloud account and set your default project.
Verifying Installation:
To verify whether the Google cloud SDK is installed on you device or not run the beow command and it will display the version of Google Cloud SDK that you installed.
Conclusion:
Setting up a Google Cloud Composer environment might seem daunting at first, but with this beginner-friendly guide, you're equipped to take the first steps toward effective workflow automation. By combining the power of Apache Airflow and the convenience of managed services, you're on your way to efficiently orchestrate your tasks.