How To Create An Azure Kubernetes Service (AKS) In Azure portal

In this article let’s explore about creating an Azure Kubernetes service (AKS) in the Azure portal. Kubernetes is a service provided by  Azure which helps in deploying and managing the clusters. From this article we will deploy an AKS cluster using the portal. Let’s make a  simple analogy about Kubernetes. Consider a bicycle shop sells a fully functional bicycle and we can ride it too. Now consider the bicycle shop instead sells you the cycle parts to fix all by yourself. So what happens here is we will totally get screwed up right? So, Kubernetes is like a bicycle shop which manages the entire deployment and managing is done easily. Now let’s get to the demo part.
 
Prerequisites
  • Active Azure Subscription.
Step 1
 
Log in into your Azure portal by using the following link
 
For creating an AKS cluster, select >> + New resource
 
Select >> Containers >> Kubernetes service.
 
How to Create an Azure Kubernetes service (AKS) in Azure portal 
 
Now we need to provide some of the basic required values such as:
  • We need to provide a unique name for the cluster.
  • Select the subscription as well as the resource group.
  • Select the region as well as the Kubernetes version if you want to, or else leave the default values to be as they are and finally click >> Review + create and Click >> Create when the validation completes.
How to Create an Azure Kubernetes service (AKS) in Azure portal
 
How to Create an Azure Kubernetes service (AKS) in Azure portal 
 
How to Create an Azure Kubernetes service (AKS) in Azure portal 
 
Step 2
 
It does take a few minutes to create an AKS cluster. When the deployment is successful we can see that the resource is running and for connecting to the cluster just open Azure PowerShell in the Azure portal itself and execute the following command in it:
  1. az aks get-credentials --resource-group myResourceGroup --name myAKSCluster  
(Replace the resource group with the resource group name you have created.)
 
Execute the following command to verify the connection with the cluster. 
  1. kubectl get nodes  
How to Create an Azure Kubernetes service (AKS) in Azure portal 
 
By executing the following commands we can get the output as mentioned below and we have to make sure that the node status is  in ready position.
 
Execute the application
 
Step 3
 
Now proceeding with the next step, we need to use either nano azure-vote.yaml or the vi azure-vote.yaml command to create a file named as azure-vote.yaml.
 
How to Create an Azure Kubernetes service (AKS) in Azure portal
 
After using nano azure-vote.yaml or vi azure-vote.yaml command open the yaml file definition and paste the following YAML definition.
  1. apiVersion: apps/v1  
  2. kind: Deployment  
  3. metadata:  
  4.   name: azure-vote-back  
  5. spec:  
  6.   replicas: 1  
  7.   selector:  
  8.     matchLabels:  
  9.       app: azure-vote-back  
  10.   template:  
  11.     metadata:  
  12.       labels:  
  13.         app: azure-vote-back  
  14.     spec:  
  15.       nodeSelector:  
  16.         "beta.kubernetes.io/os": linux  
  17.       containers:  
  18.       - name: azure-vote-back  
  19.         image: redis  
  20.         resources:  
  21.           requests:  
  22.             cpu: 100m  
  23.             memory: 128Mi  
  24.           limits:  
  25.             cpu: 250m  
  26.             memory: 256Mi  
  27.         ports:  
  28.         - containerPort: 6379  
  29.           name: redis  
  30. ---  
  31. apiVersion: v1  
  32. kind: Service  
  33. metadata:  
  34.   name: azure-vote-back  
  35. spec:  
  36.   ports:  
  37.   - port: 6379  
  38.   selector:  
  39.     app: azure-vote-back  
  40. ---  
  41. apiVersion: apps/v1  
  42. kind: Deployment  
  43. metadata:  
  44.   name: azure-vote-front  
  45. spec:  
  46.   replicas: 1  
  47.   selector:  
  48.     matchLabels:  
  49.       app: azure-vote-front  
  50.   template:  
  51.     metadata:  
  52.       labels:  
  53.         app: azure-vote-front  
  54.     spec:  
  55.       nodeSelector:  
  56.         "beta.kubernetes.io/os": linux  
  57.       containers:  
  58.       - name: azure-vote-front  
  59.         image: microsoft/azure-vote-front:v1  
  60.         resources:  
  61.           requests:  
  62.             cpu: 100m  
  63.             memory: 128Mi  
  64.           limits:  
  65.             cpu: 250m  
  66.             memory: 256Mi  
  67.         ports:  
  68.         - containerPort: 80  
  69.         env:  
  70.         - name: REDIS  
  71.           value: "azure-vote-back"  
  72. ---  
  73. apiVersion: v1  
  74. kind: Service  
  75. metadata:  
  76.   name: azure-vote-front  
  77. spec:  
  78.   type: LoadBalancer  
  79.   ports:  
  80.   - port: 80  
  81.   selector:  
  82.     app: azure-vote-front  
Step 4
 
Now we need to deploy the application using the kubectl apply command and have to specify the name of the YAML file. 
  1. kubectl apply -f azure-vote.yaml  
By executing the following command, we can get the output successfully and we can get the output as mentioned below.
 
The final part of the Kubernetes service is to run an application and the process may take a while to complete, we can watch the progress by executing the following command in –watch argument 
  1. kubectl get service azure-vote-front –watch  
How to Create an Azure Kubernetes service (AKS) in Azure portal 
 
When we execute the above watch command, we can get the following output and when we get the external-IP we can use the IP to see the application in action, for that open up the browser and enter the external IP address of the service.
 
We have discussed how to creat Azure Kubernetes service (AKS) in Azure portal and I hope this article will be useful for you. Please comment below if you have any queries and thanks for reading!