MSDN Community Blogs

Exploring the Latest in Microsoft Technologies

Getting Started with Azure Kubernetes Service (AKS)

Author Avatar

AI Assistant

Posted on

Welcome to this introductory guide on Azure Kubernetes Service (AKS). In this post, we'll walk through the fundamental steps to get you up and running with AKS, Microsoft's managed Kubernetes offering on Azure.

What is Azure Kubernetes Service (AKS)?

Azure Kubernetes Service (AKS) simplifies deploying, managing, and automating Kubernetes applications. AKS provides:

Prerequisites

Before you begin, ensure you have the following:

Step 1: Create an AKS Cluster

The easiest way to create an AKS cluster is by using the Azure CLI. Open your terminal or command prompt and run the following command:

Azure CLI

az group create --name MyResourceGroup --location eastus

az aks create --resource-group MyResourceGroup --name MyAKSCluster --node-count 1 --enable-addons monitoring --generate-ssh-keys
            

This command will:

Step 2: Connect to Your Cluster

Once the cluster is created, you need to configure your Azure CLI to connect to it. Run the following command:

Azure CLI

az aks get-credentials --resource-group MyResourceGroup --name MyAKSCluster
            

This command downloads credentials and configures your Kubernetes command-line tool (kubectl) to use them.

Step 3: Deploy a Sample Application

Now, let's deploy a simple application to your AKS cluster. We'll use a basic Nginx deployment.

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

Kubernetes Deployment YAML

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  replicas: 2
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:latest
        ports:
        - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: nginx-service
spec:
  selector:
    app: nginx
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
  type: LoadBalancer
            

Apply this configuration to your cluster using kubectl:

Kubectl

kubectl apply -f nginx-deployment.yaml
            

Step 4: Verify Your Deployment

Check the status of your deployment:

Kubectl

kubectl get deployments
kubectl get pods
            

To get the external IP address of your Nginx service, run:

Kubectl

kubectl get service nginx-service
            

You should see an output with an EXTERNAL-IP. Open this IP address in your web browser, and you should see the Nginx welcome page!

Next Steps

Congratulations! You've successfully created an AKS cluster and deployed an application. From here, you can explore:

This is just the beginning of your AKS journey. Dive deeper into the official Azure AKS documentation to unlock the full potential of Kubernetes on Azure.