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.
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.
kubeconfig file.To trigger remote Pods on an Azure AKS Cluster, the following packages and dependencies need to be added to your Docker image.
To do so, add the following commands to your Dockerfile:
kubeconfig fileThe 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 fileTo 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.
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.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.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.