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.
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
- Create a Microsoft Entra ID tenant with Global Administrator or Application Administrator privileges.
- Create a user-assigned managed identity on Azure.
- 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.
- Confirm that the OIDC credentials appear in the Managed Identity’s Federated credentials tab.
- 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
kubeconfigfile.
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
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.- External File in the default location
If the
kubeconfigfile resides in the default location on the machine (~/.kube/config), you can leave all fields empty in the connection configuration. Airflow will automatically use thekubeconfigfrom the default location. Add the followingCOPYcommand at the end of your Dockerfile to add yourkubeconfigfile inside your Astro Runtime Docker Image.
- External file with a Custom Path:
You can specify a custom path to the
kubeconfigfile by inserting the path into the Kube config path field of your Airflow Connection. Add the followingCOPYcommand at the end of your Dockerfile to add yourkubeconfigfile inside your Astro Runtime Docker Image.
- JSON Format
You can convert the
kubeconfigfile 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.