Azure Kubernetes Service (AKS) – Part 1

Azure Kubernetes Service (AKS) is a managed container orchestration service provided by Microsoft Azure public cloud. we can use AKS to deploy, scale and manage the Docker containers and container applications of container hosts on AKS Cluster.

Prerequisite for the Installation of AKS.

  1. Azure CLI with version 2.0 or higher.
  2. Azure Container Registry
  3. Install the Kubernetes CLI (kubectl)
  4. Configure kubectl to connect to your AKS cluster

We have already installed the latest version of azure-cli ie. 2.7.0, you can refer Install Azure CLI . on the other hand we can use Powreshell and Bash CLI from portal. however in this blog we are installing Azure Cli on local machine for this demo.

Create an Azure Container Registry

Azure Container Registry (ACR) is a private registry for container images and it is will let you securely build and deploy the applications and codes.

Before starting to create Azure Container Registry, we need to create a resource group.  

as we are using azure-cli we can use az group create command to create the azure resource group.

Here we are creating resource group with name AKSResourceGroup  is created in the “Central India” region:

az group create –name AKSResourceGroup  –location “Central India”

Now since the azure resource group is created, lets create an Azure Container Registry instance using az acr create command with the registry name.

Please note the registry name must be unique and should contain 5-50 alphanumeric characters. Here we are using Basic SKU.

az acr create –resource-group AKSResourceGroup  –name ACRforK8s –sku Basic

Log in to the container registry

At first we need to login to the ACR instance to use further.

Use az acr login command and provide the ACR name that we already created. 

az acr login –name ACRforK8s

The command returns a Login Succeeded message once completed.

Deploy the Azure Kubernetes Service (AKS)

As we already discussed that Kubernetes is containerized orchestration service. using AKS, we can quickly create a Kubernetes cluster to deploy applications in production/test/Dev environment.

Lets create an AKS cluster using az aks create command.

We need to have resource group, acr name handy, as we already have created resource-group with name AKSResourceGroup  and acr registry name ACRforK8s. lets created a cluster with name AK8sCluster.

az aks create –resource-group AKSResourceGroup  –name AK8sCluster –node-count 2 –generate-ssh-keys –attach-acr ACRforK8s

here we are creating AKS with name AK8sCluster and to allow the AKS cluster to interact with other Azure resources, an Azure Active Directory service principal is automatically created while creating the AKS cluster.

We have created the AKS service on Azure using the below command.  

az aks create –resource-group AKSResourceGroup  –name AK8sCluster –node-count 2 –generate-ssh-keys –attach-acr ACRforK8s

Note:  we need to have at least 2 nodes cluster for efficient and reliable functions of AKS.

Install the Kubernetes CLI

To use the kubectl service, we need to install Kubernetes CLI to connect to the Kubernetes cluster from the local computer. Please refer the link to know about kubectl,  

Lets install the kubectl service using az aks install-cli command on local machine.

az aks install-cli

Please run the below to ensure the kubectl command runs from the command prompt.  

  • Run “set PATH=%PATH%;C:\Users\vinay.singh\.azure-kubectl” or “$env:path += ‘C:\Users\vinay.singh\.azure-kubectl'” for PowerShell. This is good for the current command session.
  • Update system PATH environment variable by following “Control Panel->System->Advanced->Environment Variables”, and re-open the command window. You only need to do it once

Note: kubectl is already installed on Azure Cloud Shell. If you are planning to use.

Connect to cluster using kubectl

We need to configure kubectl to connect to the Kubernetes cluster and to achieve this we can use az aks get-credentials command.

Lets gets the credentials for the AKS cluster myAKSCluster.  

az aks get-credentials –resource-group AKSResourceGroup  –name AK8sCluster

Lets connect to azure Kubernetes cluster by running the kubectl get nodes command to show the number nodes connected to the cluster.

Kubernetes version number is expressed major.minor.patch version. For example, in version v1.15.11,  v1 is the major version, 15 is the minor version, and 11 is the patch version. 

Microsoft Azure offers Azure Kubernetes Service that simplifies managed Kubernetes cluster deployment in the public cloud environment and also manages health and monitoring of managed Kubernetes service. Customers can create AKS clusters using the Azure portal or Azure CLI and can manage the agent nodes.

In AKS, applications and supporting services run on Kubernetes nodes and the AKS cluster is a combination of one or more than one node.

These AKS nodes run on Azure Virtual Machines. Nodes that are configured with the same configuration are grouped together called node pool. Nodes in the Kubernetes cluster can be scaled-up and scaled-down according to the resources are required in the cluster.

So, nodes, clusters, and node pools are the most prominent components of your Azure Kubernetes environment.

AKS is a free container service where there would be no charge for Kubernetes cluster management. Customer need to pay only for the cloud resources such as VMs, storage, and network resources being consumed to makes it the most cost-effective container orchestration service.  We can use Container Services calculator to calculate the estimated cost of the consumed or required resources.

AKS can be easily integrated with Azure Active Directory (AD) to provide role-based access, security, and monitoring of Kubernetes architecture on the basis of identity and group membership. We can also monitor the performance of your AKS and the apps.

We will discuss about managing the AKS node-pools in another section.

1 thought on “Azure Kubernetes Service (AKS) – Part 1”

Leave a Reply

Your email address will not be published. Required fields are marked *