Read More:

Microsoft Azure for Beginners :The Role of Azure Active Directory in a Hybrid IT Environment – Part 14

Azure Kubernetes Service

When it comes to learning something new, especially in tech, hands-on experience is priceless. That’s why I’ve written this blog post. We will learn about Microsoft Azure’s Azure Kubernetes Service (AKS) by setting it up and using it ourselves.

Protect Your Data with BDRSuite

Cost-Effective Backup Solution for VMs, Servers, Endpoints, Cloud VMs & SaaS applications. Supports On-Premise, Remote, Hybrid and Cloud Backup, including Disaster Recovery, Ransomware Defense & more!

AKS is a service provided by Microsoft Azure that uses an open-source system called Kubernetes. This service makes automated launching, scaling, and managing applications easier. Kubernetes helps us manage applications stored in containers, which lets developers focus on creating applications without worrying about the infrastructure that supports them.

This is a lot to take in, so let’s break it down:

  • Microsoft Azure is a collection of cloud services for building, deploying, and managing applications
  • Kubernetes is a tool that helps us manage applications stored in containers
  • Azure Kubernetes Service (AKS) uses Kubernetes to help automate the management of containerized applications in Azure

In this blog post, we’ll set up an AKS environment step-by-step. This will give you a chance to see how AKS works in practice. By the end, you’ll have a working AKS environment and better understanding of why and how to use it.

Download Banner

So let’s dive in and learn about AKS by actually using it. Whether an AKS pro or a beginner, this hands-on guide will help you better understand this powerful service. Let’s start our learning journey together.

Deploying an Azure AKS Environment

Deploying an Azure AKS environment is simple with Azure CLI, a command-line tool for managing Azure resources.

Login to Azure

Execute the following command in your terminal to log in to Azure:

az login

Create a Resource Group

A resource group is a container with related resources for an Azure solution. Create one with the following code:

az group create –name myResourceGroup –location west Europe

Create an AKS Cluster

The following command creates an AKS cluster named “myAKSCluster”. The number of nodes is set to 1 to save costs.

az aks create –resource-group myResourceGroup –name myAKSCluster –node-count 1 –enable-addons monitoring –generate-ssh-keys

Connect to the Cluster

Use the ‘aks get-credentials’ command to connect with the cluster.

az aks get-credentials –resource-group myResourceGroup –name myAKSCluster

Deploying an Application with Azure AKS

Now that we have an AKS cluster let’s deploy a simple nginx web server application!

Create a Kubernetes Deployment

Create a file named nginx-deployment.yaml with the following content:

apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
– name: nginx
image: nginx:1.16.1
ports:
– containerPort: 80

Execute the following command to create the Deployment:
kubectl apply -f nginx-deployment.yaml

Create a Kubernetes Service

Create a file named nginx-service.yaml with the following content:

apiVersion: v1
kind: Service
metadata:
name: nginx-service
spec:
selector:
app: nginx
ports:
– protocol: TCP
port: 80
targetPort: 80
type: LoadBalancer

Execute the following command to create the Service:
kubectl apply -f nginx-service.yaml

Accessing the Web Server

It may take a few minutes to create the Azure Load Balancer. Once the Service is created, you can obtain the external IP address with the following command:

kubectl get service nginx-service

Cleaning Up the AKS Environment

Once you’ve completed your work, deleting the created resources is crucial to prevent unnecessary costs. You can easily re-deploy this environment!

Remove the Application

Execute the following commands to delete the nginx Service and Deployment we created earlier:

kubectl delete service nginx-service
kubectl delete deployment nginx-deployment

Remove the AKS Cluster

Execute the following command to delete the resource group and all the resources it contains, including the AKS cluster:

az group delete –name myResourceGroup –yes –no-wait

Remember, these steps are intended for a testing environment; a production environment would require more configuration and security measures. Always read the Azure documentation and best practices before creating a production environment.

I hope this blog post was helpful and has set you on your way to deploying and managing an Azure AKS environment. Feel free to get in touch if you have any questions or suggestions. Keep learning and keep experimenting!

Follow our Twitter and Facebook feeds for new releases, updates, insightful posts and more.

Rate this post