Running your first application on Azure Kubernetes Services

Provisioning a Kubernetes cluster to run applications on production is not an easy task, even with someone who has experience with Kubernetes. You need to take care of security (authentication & authorization), cluster upgrade, scalability & availability of your cluster. There for, the managed Kubernetes service is a good candidate when organizations want to run their containerized applications with K8S. Almost all cloud provider has their own k8s services: Google Kubernetes Engine (GKE), Azure Kubernetes Services (AKS), AWS Elastic Kubernetes Services (EKS)…

In this post, I will demonstrate the main steps to provision a Kubernetes cluster with Microsoft AKS and run a simple application on that, let’s check it out.

  • Basic knowledge of Kubernetes.
  • An Azure account with an active subscription.

What is Kubernetes?
Kubernetes is a portable, extensible, open-source platform for managing containerized workloads and services, that facilitates both declarative configuration and automation. It has a large, rapidly growing ecosystem. Kubernetes services, support, and tools are widely available.

What is Azure Kubernetes Services - AKS?
Azure Kubernetes Service (AKS) offers the quickest way to start developing and deploying cloud-native apps in Azure, datacenters, or at the edge with built-in code-to-cloud pipelines and guardrails. Get unified management and governance for on-premises, edge, and multi-cloud Kubernetes clusters. Interoperate with Azure security, identity, cost management, and migration services.

Some highlighted features of Azure Kubernetes Services

  • Automated management and scalability of Kubernetes clusters for enterprise-grade container orchestration.
  • End-to-end developer productivity with debugging, CI/CD, logging, and automated node maintenance.
  • Advanced identity and access management to monitor and maintain container security for governance at scale.
  • Support for Linux, Windows Server, and IoT resources with AKS deployment on the infrastructure of your choice using Azure Arc.

Reference: Managed Kubernetes Service (AKS) | Microsoft Azure
How to provision a managed Kubernetes cluster with Azure?

  1. Open your Azure portal ( and search for Kubernetes services.

  1. From the Kubernetes services dashboard, click Create a Kubernetes cluster

  1. Configure the basics information of the cluster

Resource group: kodekloud-aks
Cluster name: my-aks
Region: choose the nearest location.

Kubernetes version: 1.24.6 (latest at the time I write this post).
Other options leave as default values.
Then click Review & Create, wait for the validation process to finish, and click Create to request Azure provision our managed cluster.

  1. We need to wait about 5 mins until the cluster is created, time depends on the region and the configurations of our cluster.

Access your managed Kubernetes cluster.

From your Kubernetes services instance dashboard, click Connect to your cluster (we will use Cloud Shell - an integrated shell on the browser, provided by Azure). Please take note of the commands, we will use them later in the shell.

az account set --subscription {your_subscription_id}
az aks get-credentials --resource-group kodekloud-aks --name my-aks

Click “Open Cloud Shell”, and enter the 2 above commands to connect to your cluster.

We successfully connected to our managed Kubernetes services, let’s try some commands to validate.

[email protected]:~$ kubectl cluster-info
Kubernetes control plane is running at
CoreDNS is running at
Metrics-server is running at

The cluster is up and running well, with CoreDNS and a metrics server also (we can use kubectl top node/pod to monitor the consumed resources).

Running your application on AKS

We will use the k8s command to run a simple web server (httpd) by creating a deployment named my-web-server with 3 replicas.

[email protected]:~$ kubectl create deploy my-web-server --image=httpd:alpine --replicas=3 
deployment.apps/my-web-server created
[email protected]:~$ kubectl get deploy
my-web-server   3/3     3            3           33s
[email protected]:~$ kubectl get pod
NAME                             READY   STATUS    RESTARTS   AGE
my-web-server-745f5f5fb6-jspvg   1/1     Running   0          50s
my-web-server-745f5f5fb6-p7s7d   1/1     Running   0          50s
my-web-server-745f5f5fb6-rpzqg   1/1     Running   0          50s

Expose your application with Azure Load Balancer

We already created our web server, let’s create a service to expose it outside.

[email protected]:~$ kubectl expose deploy/my-web-server --type=LoadBalancer --port=80 --name=my-web-server-svc
service/my-web-server-svc exposed

[email protected]:~$ kubectl get svc
NAME                TYPE           CLUSTER-IP   EXTERNAL-IP     PORT(S)        AGE
kubernetes          ClusterIP     <none>          443/TCP        21m
my-web-server-svc   LoadBalancer   80:30776/TCP   37s

Azure will responsible for provisioning a Load Balancer and assigning a public IP to our service, in my case it is (don’t try to access this, I will delete the resources before publishing the post).

Yeah, it worked, we accomplished the target to provision a managed Kubernetes cluster, connect to it using Cloud Shell, create a web server using httpd image and publish it to the world using LoadBalancer type service.

What a long journey, hope you enjoy it and learn some valuable knowledge.

Happy learning,