Azure Kubernetes Service (AKS)

Getting Started with AKS

Welcome to the Getting Started guide for Azure Kubernetes Service (AKS). AKS simplifies deploying, managing, and scaling containerized applications using Kubernetes on Azure.

1

Prerequisites

Before you begin, ensure you have the following:

  • An active Azure subscription. If you don't have one, you can sign up for a free account.
  • The Azure CLI installed and configured. You can download it from here.
  • Basic understanding of containers (Docker) and Kubernetes concepts.
2

Create an AKS Cluster

Use the Azure CLI to create a new AKS cluster. This command creates a cluster named 'myAKSCluster' in the 'eastus' region with one node. You can customize these parameters as needed.

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 process can take several minutes to complete.

3

Connect to the Cluster

Once the cluster is created, configure your Kubernetes command-line tool, kubectl, to connect to your cluster.

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

This command downloads credentials and configures the Kubernetes CLI for use.

4

Deploy an Application

Let's deploy a simple sample application. This example uses a basic NGINX deployment and exposes it via a Kubernetes service.

First, create a YAML file named azure-vote.yaml with the following content:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: azure-vote-back
spec:
  replicas: 1
  selector:
    matchLabels:
      app: azure-vote-back
  template:
    metadata:
      labels:
        app: azure-vote-back
    spec:
      containers:
      - name: azure-vote-back
        image: mcr.microsoft.com/oss/bitnami/redis:6.0.8
        env:
        - name: ALLOW_EMPTY_PASSWORD
          value: "yes"
        resources:
          requests:
            cpu: 100m
            memory: 128Mi
          limits:
            cpu: 100m
            memory: 128Mi
---
apiVersion: v1
kind: Service
metadata:
  name: azure-vote-back
spec:
  selector:
    app: azure-vote-back
  ports:
    - protocol: TCP
      port: 6379
      targetPort: 6379
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: azure-vote-front
spec:
  replicas: 1
  selector:
    matchLabels:
      app: azure-vote-front
  template:
    metadata:
      labels:
        app: azure-vote-front
    spec:
      containers:
      - name: azure-vote-front
        image: mcr.microsoft.com/azuredocs/azure-vote-frontend:v1
        ports:
        - containerPort: 80
        env:
        - name: REDIS_HOST
          value: "azure-vote-back"
        resources:
          requests:
            cpu: 100m
            memory: 128Mi
          limits:
            cpu: 100m
            memory: 128Mi
---
apiVersion: v1
kind: Service
metadata:
  name: azure-vote-front
spec:
  type: LoadBalancer
  ports:
    - port: 80
  selector:
    app: azure-vote-front

Now, deploy the application using kubectl:

kubectl apply -f azure-vote.yaml
5

View the Application

The deployment will take a minute or two to complete. To see the status of the deployments, use kubectl get services:

kubectl get services azure-vote-front

Look for the EXTERNAL-IP address for the azure-vote-front service. It may take a few minutes for this IP address to be assigned.

Once you have an external IP address, open it in your web browser to view the sample application.

6

Clean Up Resources

To avoid ongoing charges, delete the resource group containing your AKS cluster and related resources.

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

Congratulations! You've successfully deployed an application to Azure Kubernetes Service. Explore the advanced topics to learn more about managing and scaling your applications.

Explore Advanced Topics