Skip to main content
If some of your tasks require specific resources such as a GPU, you might want to run them in a different cluster than your Airflow instance. In setups where both clusters are used by the same AWS, Azure or GCP account, you can manage separate clusters with roles and permissions.
To launch Pods in external clusters from a local Airflow environment, you must have valid authentication for the external cluster so that your local Airflow environment has permissions to launch a Pod in the external cluster. For managed Kubernetes services from public cloud providers, authentication is federated through the native IAM service. To grant the Astro role permissions to launch pods on your cluster, you can either include static credentials or use workload identity to authorize the Astro role to your cluster.
This example shows how to configure an Azure Managed Identity (MI) to run a Pod on an AKS cluster from an Airflow instance where cross-account access is not available.

Prerequisites

  • Network connectivity between your Airflow execution environment and the external Kubernetes cluster:
    • Hosted execution mode: A network connection between your Astro Deployment and the external cluster.
    • Remote execution mode: Network connectivity between the environment where your Remote Execution Agent runs and the external cluster. You are responsible for managing this connectivity. A direct network connection between Astro and the external cluster is not required.

Setup

1

Set Up Azure Managed Identity

  1. Create a Microsoft Entra ID tenant with Global Administrator or Application Administrator privileges.
  2. Create a user-assigned managed identity on Azure.
  3. Authorize your Astro Deployment to Azure using Azure Managed Identity (MI) by following steps 1 and 2 described in the Deployment Workload identity set up.
  4. Confirm that the OIDC credentials appear in the Managed Identity’s Federated credentials tab.
  5. From the Managed Identity’s Properties tab, note the Client ID. From your Azure Portal, go to Azure Active Directory (Microsoft Entra ID) and note the Tenant ID. Both the Client ID and Tenant ID will be needed in Step 3 to configure your kubeconfig file.
2

Install dependencies in your Astro Runtime Docker Image

To trigger remote Pods on an Azure AKS Cluster, the following packages and dependencies need to be added to your Docker image.
  • Azure CLI
  • Kubectl
  • Kubelogin
To do so, add the following commands to your Dockerfile:
Dockerfile
3

Configure your `kubeconfig` file

The following configuration file below is a sample Kubernetes kubeconfig file that allows the Kubernetes command-line tool, kubectl, or other clients to connect to a remote Kubernetes cluster, remote-kpo, using Azure Workload Identity for authentication.
kubeconfig
4

Create an Airflow Connection to use the `kubeconfig` file

To use the kubeconfig file, you will need to create a new Kubernetes Airflow Connection.There are multiple ways to pass the kubeconfig file to your Airflow Connection. If your kubeconfig file contains any sensitive information, we recommend storing it as JSON inside the connection, described in option 3.
  1. External File in the default location If the kubeconfig file resides in the default location on the machine (~/.kube/config), you can leave all fields empty in the connection configuration. Airflow will automatically use the kubeconfig from the default location. Add the following COPY command at the end of your Dockerfile to add your kubeconfig file inside your Astro Runtime Docker Image.
  1. External file with a Custom Path: You can specify a custom path to the kubeconfig file by inserting the path into the Kube config path field of your Airflow Connection. Add the following COPY command at the end of your Dockerfile to add your kubeconfig file inside your Astro Runtime Docker Image.
  1. JSON Format You can convert the kubeconfig file to JSON format and paste it into the Kube config (JSON format) field in the connection configuration. Use an online converter like https://jsonformatter.org/yaml-to-json to convert YAML to JSON. Remove any sensitive information first.
5

Configure your task

Run a Kubernetes Pod with Airflow KubernetesPodOperator.