Quickstart: Deploy an Application to AKS

This guide will walk you through deploying a sample application to your Azure Kubernetes Service (AKS) cluster.

Note: Ensure you have followed the previous steps to create an AKS cluster and have the Azure CLI installed and configured.

Step 1: Connect to your AKS Cluster

First, you need to configure your Kubernetes command-line tool, kubectl, to connect to your AKS cluster. Use the following command, replacing <your-cluster-name> and <your-resource-group> with your specific cluster details.

az aks get-credentials --resource-group <your-resource-group> --name <your-cluster-name>

Verify the connection by listing the nodes in your cluster:

kubectl get nodes

Step 2: Prepare your Application

For this quickstart, we'll use a simple sample application. You can replace this with your own containerized application.

First, create a Kubernetes deployment file (e.g., azure-vote-front.yaml):

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-front:v1 ports: - containerPort: 80 env: - name: AZURE_VOTE_BACKEND value: "http://localhost:8080"

Next, create a Kubernetes service file (e.g., azure-vote-service.yaml):

apiVersion: v1 kind: Service metadata: name: azure-vote-front-service spec: ports: - port: 80 selector: app: azure-vote-front type: LoadBalancer

Step 3: Deploy the Application

Apply these YAML files to your AKS cluster using kubectl:

kubectl apply -f azure-vote-front.yaml kubectl apply -f azure-vote-service.yaml

It may take a few minutes for the services to provision and become available. You can check the status of your deployment and service:

kubectl get deployment azure-vote-front kubectl get service azure-vote-front-service

Step 4: Access your Application

Once the service is provisioned, you'll get an external IP address for your application. You can find this by running:

kubectl get service azure-vote-front-service

Look for the EXTERNAL-IP field. This might take a minute or two to appear. Open a web browser and navigate to the external IP address to see your deployed application.

Cleanup: To avoid incurring ongoing charges, remember to delete the AKS cluster and related resources when you are finished. You can do this via the Azure portal or using the Azure CLI.

Next: Manage Your Applications