Overview
Azure Kubernetes Service (AKS) is Microsoft Azure’s managed Kubernetes solution. It competes with both Google Kubernetes Engine (GKE) and Amazon Elastic Kubernetes Service (EKS). In this post, I will walk you through different ways of creating a cluster.
Install AZ CLI, Kubectl
In this section, Install the required CLI’s in your local machine which will be used to connect to AKS clusters once deployed.
- Download and install the AZ command line tool at its install page. It will help you create and communicate with AKS cluster. Once cli is successfully installed, configure the same using below steps:
kubectl
is the command-line client for directly interacting with a Kubernetes cluster. The Azure CLI provides a sub-command that will installkubectl
for you or can be installed by following the steps here.
Create AKS cluster through console
- Login to Azure portal > Search for resources > Kubernetes services > Create > Create a Kubernetes cluster
- Use existing resource group or create a new one as shown below:
- Cluster details:
-
- Cluster present configuration – select Standard or Dev etc .. from drop down, I choose standard for this demo purpose
- Kubernetes cluster name: Give a name # Ex: captain-aks-cluster-1
- Region: Select a region # (Asia Pacific) South India
- Kubernetes Version: select default or any other version
-
- Primary node pool:
-
- Node size: Leave to default or select a diff size
- Scale method: leave to default – Autoscale
- Node count range: provide min and max num of nodes and click on Next: Node pools
-
- Node pools: You can add node pools, for this demo I didn’t add any pools.
- Authentication: select Service principal
-
- Open a new tab > Login to Azure portal > search for Azure Active Directory > App registrations > select the principal (follow the steps here to create a new service principal)
- Click on service principal > Overview > Application (client) ID : This is the Service principal client ID
- In the same page > Manage > Certificates & Secrets > New client secret > Add > copy the value and save it in a safe location for later use. This is the Service principal client secret
-
- Review + Create
- Create
Once the cluster is successfully created, cluster status should turn Succeeded (Running)
Create AKS cluster through CLI
Note: This section is optional if you also want to deploy AKS cluster using terminal. If you have already deployed a cluster through console then jump to next section to deploy a test application.
Create ACR (Optional):
In this demo, I will be using ACR (Azure Container Registries) to store the images. You can deploy the application with images located in any registry of your choice.
- Login to Azure portal > Container registries > Create container registry
- In Resource Group, create new as shown below and give it a name
- Give a registry name and select the Location from drop down.
- Review + Create
- Create
- Login to Azure portal > Container registries > click on registry > Repositories
- Image pushed in previous step can be seen here
Deploy an Application
- As the cluster is deployed in previous step, now let’s understand how to connect.
- Click on deployed AKS cluster > Connect
- Run the commands that is displayed on right pane of the page once Connect option is clicked. I have also shown examples below: