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:
An Azure subscription.
The Azure CLI installed.
Minikube: Install Minikube on your local machine so you can run Kubectl commands. https://minikube.sigs.k8s.io/docs/start/
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:
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.
Creating the AKS Cluster
This command creates an AKS cluster with a default node pool. This command creates an AKS cluster named "MyAKSCluster".
verify:
Step 3:Connecting to the Cluster
Connect kubectl to your AKS cluster:
Copy code
Verifying the Cluster
To verify that your AKS cluster is up and running, execute the following command:
Step 4: Create the "frontend" Namespace
Execute the following command to create the "frontend" namespace:
Verify the Namespace
To confirm that the "frontend" namespace has been created, run:
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
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
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.
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.
Verify the Service
You can get the external IP address assigned to your service using:
Copy code
Access NGINX
Once you have the external IP, you can access the application through your browser using http:///.
Check Pods
Check Replica Sets
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:
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)