|
| 1 | +--- |
| 2 | +title: 'Connect to AKS Private Cluster Using Azure Bastion (Preview)' |
| 3 | +titleSuffix: Azure Bastion |
| 4 | +description: Learn how to securely connect to Azure Kubernetes Service (AKS) private clusters using Azure Bastion's native client tunneling. Step-by-step guide with prerequisites and commands to establish secure access without exposing endpoints. |
| 5 | +author: abell |
| 6 | +ms.service: azure-bastion |
| 7 | +ms.topic: how-to |
| 8 | +ms.date: 07/29/2025 |
| 9 | +ms.author: abell |
| 10 | + |
| 11 | +# Customer intent: "As a cloud administrator, I want to establish a secure connection to an AKS private cluster using Azure Bastion, so that I can access my Kubernetes resources without exposing them to the public internet." |
| 12 | +--- |
| 13 | + |
| 14 | +# Connect to AKS Private Cluster Using Azure Bastion (Preview) |
| 15 | + |
| 16 | +This article shows you how to connect to Azure Kubernetes Service (AKS) private clusters securely using Azure Bastion's native client tunneling feature. You learn to establish secure connections to AKS private clusters in Azure virtual networks without exposing endpoints to the public internet, eliminating the need for additional client software or agents. |
| 17 | + |
| 18 | +Azure Bastion provides secure connectivity to all resources in the virtual network in which it's provisioned. Using Azure Bastion protects your AKS clusters from exposing endpoints to the outside world, while still providing secure access. For more information, see [What is Azure Bastion?](bastion-overview.md) For more information about AKS private clusters, see [Create a private Azure Kubernetes Service cluster](/azure/aks/private-clusters). |
| 19 | + |
| 20 | +## Prerequisites |
| 21 | + |
| 22 | +Before you begin, verify that you've met the following criteria: |
| 23 | + |
| 24 | + |
| 25 | +* A virtual network with the Bastion host already installed. |
| 26 | + |
| 27 | + * Make sure that you have set up an Azure Bastion host for the virtual network in which the AKS cluster is located. Once the Bastion service is provisioned and deployed in your virtual network, you can use it to connect to any AKS private cluster in the virtual network. |
| 28 | + * To set up an Azure Bastion host, see [Quickstart: Deploy Bastion with default settings](quickstart-host-portal.md). |
| 29 | + * The Bastion must be Standard or Premium SKU and have native client support enabled under configuration settings. |
| 30 | + |
| 31 | +* An AKS cluster in the virtual network or any reachable virtual network. |
| 32 | + |
| 33 | +## Required roles |
| 34 | + |
| 35 | + |
| 36 | +* Reader role on the AKS cluster. |
| 37 | +* Reader role on the Azure Bastion resource. |
| 38 | +* Reader role on the virtual network of the target AKS cluster (if the Bastion deployment is in a peered virtual network). |
| 39 | + |
| 40 | +## Additional requirements |
| 41 | + |
| 42 | +* If you're using Bastion to connect to a public cluster with API server authorized IP ranges, you need to add the public IP address of the Bastion to the list of authorized IP ranges of your cluster. |
| 43 | + |
| 44 | +## Limitations |
| 45 | + |
| 46 | +This integration with AKS is currently in preview and doesn't support AKS clusters with public FQDN disabled. |
| 47 | + |
| 48 | +## Connect |
| 49 | + |
| 50 | +To connect to your AKS private cluster: |
| 51 | + |
| 52 | +1. Sign in to your Azure account using `az login` via CLI. If you have more than one subscription, you can view them using `az account list` and select the subscription containing your Bastion resource using: |
| 53 | + |
| 54 | + ```pwsh |
| 55 | + az account set --subscription <subscription ID> |
| 56 | + ``` |
| 57 | + |
| 58 | +1. Retrieve credentials to your AKS private cluster: |
| 59 | + |
| 60 | + ```pwsh |
| 61 | + az aks get-credentials --admin --name <AKSClusterName> --resource-group <ResourceGroupName> |
| 62 | + ``` |
| 63 | + |
| 64 | +1. Open the tunnel to your target AKS Cluster with either of the following commands: |
| 65 | + |
| 66 | + ```pwsh |
| 67 | + az aks bastion --name <aksClusterName> --resource-group <aksClusterResourceGroup> --admin --bastion <bastionResourceId> |
| 68 | + ``` |
| 69 | + |
| 70 | + Or: |
| 71 | + |
| 72 | + ```pwsh |
| 73 | + az network bastion tunnel --name <BastionName> --resource-group <ResourceGroupName> --target-resource-id <AKSClusterID> --resource-port 443 --port <LocalMachinePort> |
| 74 | + ``` |
| 75 | + |
| 76 | +1. If you're using the az network command, open a new command line to connect to the AKS cluster via the Bastion tunnel. Otherwise, you should be all set to interact with your AKS cluster. |
| 77 | + |
| 78 | + ```pwsh |
| 79 | + kubectl get pods --server=https://localhost:<LocalMachinePort> |
| 80 | + ``` |
| 81 | + |
| 82 | +## Next steps |
| 83 | + |
| 84 | +Read the [Bastion FAQ](bastion-faq.md) for more connection information. |
0 commit comments