DEV Community

Cover image for Effortless Kubernetes Management: Creating and Scaling Workloads on Azure AKS with Azure CLI
Abisola Adesegun
Abisola Adesegun

Posted on • Updated on

Effortless Kubernetes Management: Creating and Scaling Workloads on Azure AKS with Azure CLI

Table of contents
Step 1: Prerequisites
Step 2: Create an AKS Cluster
Step 3:Connecting to the Cluster
Step 4: Create the "frontend" Namespace
Step 5: Deploy a Kubernetes Workload
Step 6: Expose the Deployment and verify
Step 7: Cleanup Resources
Step 8: Conclusion

Managing Kubernetes clusters on Azure Kubernetes Service (AKS) using the Azure CLI provides a powerful yet effortless way to create, deploy, and scale workloads. With AKS, Microsoft Azure offers a fully managed Kubernetes solution that reduces the operational overhead of managing clusters, and the Azure CLI allows for seamless management through command-line operations.
Here's a guide to help you create and scale workloads using AKS and the Azure CLI:

Step 1: Prerequisites
Before getting started, ensure that you have:

Step 2: Create an AKS Cluster
Create a New Folder
Make a new hidden folder called ".ssh". This will store our generated ssh keys.

You can open your terminal and input the following commands:

Image description

Image description

Image description

Create a Resource Group
A Resource Group is a container for managing and organizing related Azure resources. You'll need a resource group to hold your AKS cluster.

Copy code
Image description

Image description

Creating the AKS Cluster
This command creates an AKS cluster with a default node pool. This command creates an AKS cluster named "MyAKSCluster".

Image description

verify:

Image description

Image description

Image description

Step 3:Connecting to the Cluster
Connect kubectl to your AKS cluster:

Copy code

Image description

Image description

Verifying the Cluster
To verify that your AKS cluster is up and running, execute the following command:

Image description

Image description

Step 4: Create the "frontend" Namespace
Execute the following command to create the "frontend" namespace:

Image description

Image description

Verify the Namespace
To confirm that the "frontend" namespace has been created, run:

Image description

Image description

Step 5: Deploy a Kubernetes Workload
Create a Deployment
You can create a deployment using either a manifest file or directly from the CLI. To create a deployment directly, use this command:

Copy code

Image description

Image description

Create NGINX Deployment
Execute the following command to create a basic NGINX deployment with three replicas.This command creates a deployment named nginx-deployment using the official NGINX Docker image with three replicas.

Copy code

Image description

Image description

Verify the Deployment
Check the status of your NGINX deployment. You will see the nginx-deployment listed with the desired and current replicas both set to 3.

Image description

Image description

Step 6: Expose the Deployment and verify

  • Expose the Deployment To access the application, expose the deployment via a Kubernetes service:

Copy code:

kubectl expose deployment nginx-deployment --name=nginx-service --port=80 --type=LoadBalancer

This creates a load-balanced service that forwards traffic to the nginx pods.

Image description

Verify the Service
You can get the external IP address assigned to your service using:

Copy code

Image description

Image description

Access NGINX
Once you have the external IP, you can access the application through your browser using http:///.

Image description

Check Pods

Image description

Check Replica Sets

Image description

Step 7: Cleanup Resources
When you're finished with your AKS cluster, it's important to delete the resources to avoid unnecessary charges. Run the following commands:

Image description

Image description

Image description

Step 8: Conclusion
Using the Azure CLI with AKS simplifies Kubernetes cluster management, making it easy to create, scale, and monitor workloads. This approach gives developers and administrators an effortless, powerful solution to deploy and manage containerized applications in the cloud with minimal operational burden.

Top comments (0)