What is Kubernetes?
Kubernetes, also known as K8s, is an open-source system for automating the deployment, scaling, and management of containerized applications. It groups containers that make up an application into logical units for easy management and discovery.
Kubernetes Architecture Diagram
What is an AKS cluster?
AKS (Azure Kubernetes Service) is Azure’s managed container service and it is an open-source fully managed container orchestration service. It manages your hosted Kubernetes environment, making it simple to deploy and manage containerized applications without container orchestration expertise, divesting much of that responsibility to Azure. This service offers to provision, scaling, and upgrades of resources as per requirement or demand without any downtime in the Kubernetes cluster.
Prerequisite
Azure portal account.
Azure CLI installed.
Terraform installed.
Configure AKS Cluster Using the Azure portal
Steps:
Login to the Azure portal and click the Kubernetes services or you can search for it on the search bar.
Click on Create --> Create a Kubernetes cluster
As I am on free trial, so I filled that as Subscription --> ResourceGroup ( I created a new RG i.e AKS-RG)
Fill in the Cluster details as per your requirement. As I am doing it for testing propose and do not want to incur much costs, I choose the below details.
Choose the node size as per your requirement. You can change the size and number of CPU and RAM --> Scale mode (autoscale) --> Node Count range(min-1 and max-2)
Keep all things as default. If you want to add extra node pools you can add them.
Keep below all things as default and navigate to Review + create section. Click on Create.
Connecting to AKS cluster
Steps:
Once the cluster is created --> select your cluster --> Connect --> Azure CLI.
You will see the steps to connect to the cluster.
After you have downloaded Azure CLI on your system. Run the command
\>> az login
A window will pop out which will ask for your credentials to your Azure portal. Login to that using your credentials.
Note: If you find the below error then follow the next steps.
After you log in, if you see the above error then go to your portal --> search tenant properties --> Yes (Access management for Azure Resources)
Now login again. You have been successfully logged in.
Follows the remaining commands for AKS Configuration as shown below.
Kudos you have been connected to the AKS cluster.
AKS Cluster Provisioning through Terraform
Steps:
Create a provider.tf configuration file with the below details.
provider "azurerm" { features {} subscription_id = "*************" tenant_id = "*************" }
Create a resource group as shown below.
resource "azurerm_resource_group" "resource-grp" { name = "cluster-rg" location = "Central India" }
Create a resource block for AKS cluster configuration as shown below.
resource "azurerm_kubernetes_cluster" "example" { name = "aks-cluster" location = azurerm_resource_group.resource-grp.location resource_group_name = azurerm_resource_group.resource-grp.name dns_prefix = "exampleaks1" kubernetes_version = "1.25.6" default_node_pool { name = "default" node_count = 1 vm_size = "Standard_D2_v2" } identity { type = "SystemAssigned" } tags = { Environment = "Testing" } }
Now run terraform init ---> terraform plan --->terraform apply command to create an cluster.
You can view your cluster has been created and to connect it follow the above procedure.
Visit this GitHub link for terraform code.
This blog is Part I of the blog name "Deploy a Web App to an AKS Cluster using AWS Codepipeline and ArgoCD" for which an AKS cluster is needed. Please check out my blog for more details.
Thank you for reading my blog. Happy learning