DevZero Logo
DevZero

Azure Kubernetes Service (AKS)

Connecting to an Azure Kubernetes Service from a DevZero workspace.

You are connecting to a Kubernetes cluster running in the private subnet of Azure Virtual Network (VNET) from your DevBox.

Architecture Diagram

Azure KS Architecture

Here, you will connect to a Kubernetes cluster running in a private subnet from your DevBox. This would be done by setting up a bastion host that advertises the VNET CIDR to your DevZero network so that you can access the private service through the network tunneling.

Prerequisites

Before you begin, follow the Connecting to Azure guide to set up the Bastion Host to access your private Azure services.

Existing Azure Kubernetes Cluster

Step 1: Installing the necessary tools in DevBox

To connect to AKS running in the private subnet, ensure it is within the same Resource Group and VNET containing the Bastion Host.

If the above criteria are followed, then log into your DevBox and follow these steps:

  1. Go to your DevBox and install Azure CLI:
sudo curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
  1. After the installation is successful, you need to authenticate your Microsoft Azure account with Azure CLI using the following command:
az login
  1. Following your setup with Azure CLI, you also need to download the kubectl binaries:
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
  1. Install kubectl:
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl

Step 2: Accessing your AKS Cluster from DevBox

After your initial setup is done, your DevBox should be ready for accessing the cluster:

  1. You need to select your Subscription ID in Azure Cli with the following command:
az account set --subscription <subscription-id>
  1. Use the following command to connect to your cluster:
az aks get-credentials --resource-group <resource-group-name> --name <cluster-name> --overwrite-existing
  1. Check if the cluster is accessible:
kubectl get svc

GCP GKE -> Devbox

New Azure Kubernetes Cluster

If you need to make a new AKS Cluster running in a private subnet and access it through DevZero's network, then follow the below steps:

Step 1: Creating a Kubernetes Cluster

  1. Go to Home > Kubernetes Services or you can search for Azure Kuberntes Service in the search bar and click on Create Kubernetes Cluster.
  2. In the Basics section, select the resource group you previously selected for your VNET.
  3. Enter your Cluster name and region and choose your desired node image.
  4. Select your desired Node Pool machine configuration in the Node Pools section.
  5. Go to the Networking section and check the Enable private cluster and Bring your own Azure virtual network options, respectively.
  6. After checking these two options, you will be asked to choose your VNET. Then, create a new subnet dedicated to Kubernetes and choose that subnet.
  7. Enter a Kubernetes service address range that doesn't overlap with your VNET CIDR. For Example, if your VNET CIDR Range is 10.0.0.0/16, then it is recommended that you make your Kubernetes service address range 192.168.0.0/16.
  8. Provide a Kubernetes DNS service IP Address and enter your DNS name prefix.
  9. Click on Review + Create and click on Create to create Kubernetes Cluster.

Step 2: Installing the necessary tools in DevBox

Now that you have created the cluster, you need to authenticate your DevBox with the az cli tool:

  1. Go to your DevBox and install Azure CLI:
sudo curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
  1. After the installation is successful, you need to authenticate your Microsoft Azure account with Azure CLI using the following command:
az login
  1. Following your setup with Azure CLI, you also need to download the kubectl binaries:
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
  1. Install kubectl:
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl

Step 3: Accessing your Azure Kubernetes Cluster from DevBox

After your initial setup is done, your DevBox should be ready for accessing the cluster:

  1. You need to select your Subscription ID in Azure CLI with the following command:
az account set --subscription <subscription-id>
  1. Use the following command to connect to your cluster:
az aks get-credentials --resource-group <resource-group-name> --name <cluster-name> --overwrite-existing
  1. Check if the cluster is accessible:
kubectl get svc

GCP GKE -> Devbox