How to Create an Azure Kubernetes Cluster and Deploy an Application Using Azure CLI

Introduction

Azure Kubernetes Service (AKS) cluster is a managed container orchestration platform provided by Microsoft Azure. It enables the deployment, scaling, and management of containerized applications using Kubernetes.

Kubernetes is …


This content originally appeared on DEV Community and was authored by Sarah Aligbe

Introduction

Azure Kubernetes Service (AKS) cluster is a managed container orchestration platform provided by Microsoft Azure. It enables the deployment, scaling, and management of containerized applications using Kubernetes.

Kubernetes is an open-source container orchestration system that helps you manage and automate the deployment, scaling, and management of containerized applications.

AKS clusters simplify the deployment and management of applications by abstracting away the underlying infrastructure complexities. They offer benefits such as automatic scaling, load balancing, and high availability. AKS clusters provide a reliable and scalable environment for running containerized applications on Azure.

Azure CLI (Command-Line Interface) is a powerful command-line tool for managing Azure resources. It provides a convenient and efficient way to interact with Azure services, including the creation and management of AKS clusters. Azure CLI offers a consistent experience across platforms and can be easily scripted, allowing for automation and streamlined workflows.

Pre-requisites

Before diving into creating an AKS cluster and deploying applications, ensure you have the following prerequisites in place:

  1. An Azure subscription: Sign up for an Azure account if you don't have one.
  2. Azure CLI installed: Install Azure CLI on your local machine.
  3. Kubectl installed
  4. Working knowledge of Kubernetes.
  5. Authenticate Azure CLI with your Azure account by running the command below and following the prompts:
az login

Setting up an AKS Cluster

Step 1. Create a resource group. A resource group is a logical container that holds related Azure resources.

az group create --name <resource-group-name> --location <azure-region>

resource group

Step 2. Create the AKS cluster

az aks create --resource-group <resource-group-name> \
--name <aks-cluster-name> \
--node-count 2 \
--generate-ssh-keys
  • --resource-group: Specifies the name of the resource group where the AKS cluster will be created. Replace with the desired name of the resource group.
  • --name: Specifies the name of the AKS cluster to be created. Replace with the desired name of the AKS cluster.
  • --node-count: Specifies the number of nodes (virtual machines) that should be provisioned in the AKS cluster. In this example, we have set the node count to 2, but you can adjust it based on your application requirements.
  • --generate-ssh-keys: Generates SSH public and private keys to be used for accessing the cluster nodes. This parameter simplifies the process of managing SSH keys. Azure CLI will automatically generate the keys and configure them for you.

create aks

aks successful

Step 3. Get cluster credentials

az aks get-credentials --name <aks-cluster-name> --resource-group <resource-group-name 

By executing this command, Azure CLI retrieves the necessary credentials, including the Kubernetes cluster endpoint and authentication token, and configures the Kubernetes context on your local machine. This allows you to interact with the AKS cluster using Kubernetes command-line tools (kubectl) or any other Kubernetes client.

aks cluster credentials

You can run kubectl get nodes to see the nodes in your cluster.

Step 4. Clone the azure voting app github repo here.
The repo already has the Kubernetes deployment and service files needed to deploy the application.

Step 5. Deploy the application.
A Kubernetes manifest file containing all the deployments and services is in the azure-vote-all-in-one-redis.yml file. To deploy this manifest, run this command:

kubectl apply -f azure-vote-all-in-one-redis.yml

kubectl apply

Step 6. Visit your deployed site
The azure voting frontend has a service type of LoadBalancer, in order to visit your newly deployed site run the following command to get the external IP address of the LoadBalancer:

kubectl get service --watch

The --watch flag is added because the external IP address takes a little while before it is added to the LoadBalancer so instead of running the command multiple times, just add the watch flag to watch for any changes.

loadbalancer external ip
Copy the external IP and paste in your web browser to see the azure voting app website.

live site

Step 7. Clean up your resources
It is important to clean up resources when you no longer have use for them to avoid incurring charges. To delete your resources, simply delete the resource group with the command below:

az group delete --name <resource-group-name>

Conclusion

Throughout this article, we covered key steps for creating an AKS cluster and deploying applications using Azure CLI. We created a resource group, an AKS cluster, and deployed the Azure voting application to our cluster.

By leveraging Azure CLI and the power of AKS clusters, you can efficiently deploy and manage your applications on Azure, taking advantage of the scalability and flexibility of Kubernetes. Happy exploring and deploying your applications on Azure


This content originally appeared on DEV Community and was authored by Sarah Aligbe


Print Share Comment Cite Upload Translate Updates
APA

Sarah Aligbe | Sciencx (2023-05-19T01:08:40+00:00) How to Create an Azure Kubernetes Cluster and Deploy an Application Using Azure CLI. Retrieved from https://www.scien.cx/2023/05/19/how-to-create-an-azure-kubernetes-cluster-and-deploy-an-application-using-azure-cli/

MLA
" » How to Create an Azure Kubernetes Cluster and Deploy an Application Using Azure CLI." Sarah Aligbe | Sciencx - Friday May 19, 2023, https://www.scien.cx/2023/05/19/how-to-create-an-azure-kubernetes-cluster-and-deploy-an-application-using-azure-cli/
HARVARD
Sarah Aligbe | Sciencx Friday May 19, 2023 » How to Create an Azure Kubernetes Cluster and Deploy an Application Using Azure CLI., viewed ,<https://www.scien.cx/2023/05/19/how-to-create-an-azure-kubernetes-cluster-and-deploy-an-application-using-azure-cli/>
VANCOUVER
Sarah Aligbe | Sciencx - » How to Create an Azure Kubernetes Cluster and Deploy an Application Using Azure CLI. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2023/05/19/how-to-create-an-azure-kubernetes-cluster-and-deploy-an-application-using-azure-cli/
CHICAGO
" » How to Create an Azure Kubernetes Cluster and Deploy an Application Using Azure CLI." Sarah Aligbe | Sciencx - Accessed . https://www.scien.cx/2023/05/19/how-to-create-an-azure-kubernetes-cluster-and-deploy-an-application-using-azure-cli/
IEEE
" » How to Create an Azure Kubernetes Cluster and Deploy an Application Using Azure CLI." Sarah Aligbe | Sciencx [Online]. Available: https://www.scien.cx/2023/05/19/how-to-create-an-azure-kubernetes-cluster-and-deploy-an-application-using-azure-cli/. [Accessed: ]
rf:citation
» How to Create an Azure Kubernetes Cluster and Deploy an Application Using Azure CLI | Sarah Aligbe | Sciencx | https://www.scien.cx/2023/05/19/how-to-create-an-azure-kubernetes-cluster-and-deploy-an-application-using-azure-cli/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.