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.
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.
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:
- 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.
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.
After using nano azure-vote.yaml or vi azure-vote.yaml command open the yaml file definition and paste the following YAML definition.
- apiVersion: apps/v1
- kind: Deployment
- metadata:
- name: azure-vote-back
- spec:
- replicas: 1
- selector:
- matchLabels:
- app: azure-vote-back
- template:
- metadata:
- labels:
- app: azure-vote-back
- spec:
- nodeSelector:
- "beta.kubernetes.io/os": linux
- containers:
- - name: azure-vote-back
- image: redis
- resources:
- requests:
- cpu: 100m
- memory: 128Mi
- limits:
- cpu: 250m
- memory: 256Mi
- ports:
- - containerPort: 6379
- name: redis
- ---
- apiVersion: v1
- kind: Service
- metadata:
- name: azure-vote-back
- spec:
- ports:
- - port: 6379
- selector:
- app: azure-vote-back
- ---
- apiVersion: apps/v1
- kind: Deployment
- metadata:
- name: azure-vote-front
- spec:
- replicas: 1
- selector:
- matchLabels:
- app: azure-vote-front
- template:
- metadata:
- labels:
- app: azure-vote-front
- spec:
- nodeSelector:
- "beta.kubernetes.io/os": linux
- containers:
- - name: azure-vote-front
- image: microsoft/azure-vote-front:v1
- resources:
- requests:
- cpu: 100m
- memory: 128Mi
- limits:
- cpu: 250m
- memory: 256Mi
- ports:
- - containerPort: 80
- env:
- - name: REDIS
- value: "azure-vote-back"
- ---
- apiVersion: v1
- kind: Service
- metadata:
- name: azure-vote-front
- spec:
- type: LoadBalancer
- ports:
- - port: 80
- selector:
- 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.
- 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
- kubectl get service azure-vote-front –watch
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!