Harshan Rajendran

AZURE KUBERNETES SERVICES (AKS)

Step-by-Step Guide to Setting Up Azure Kubernetes Service (AKS) πŸš€

Azure Kubernetes Service (AKS) allows you to deploy, manage, and scale containerized applications using Kubernetes without handling complex infrastructure. Here’s a clear step-by-step guide to setting it up.


πŸ› οΈ Step 1: Sign in to Azure Portal

  1. Go to Azure Portal.
  2. Sign in with your Microsoft Azure account.

πŸ“¦ Step 2: Create an AKS Cluster

  1. Click “Create a resource” (top left corner).
  2. Search for “Kubernetes Service” and select “Create”.

πŸ”§ Step 3: Configure Basics

βœ… Subscription: Select your Azure subscription.
βœ… Resource Group: Create a new one or use an existing one.
βœ… Kubernetes Cluster Name: Enter a unique name (e.g., myAKSCluster).
βœ… Region: Choose a data center closest to your users.
βœ… Kubernetes Version: Choose the latest stable version.


πŸ’» Step 4: Configure Node Pools

  1. Choose Node Size (Standard_B2s is good for testing, but you can scale later).
  2. Set Node Count (start with 1 or 2 for testing).
  3. Enable Auto-scaling (optional, useful for scaling workloads).

πŸ”’ Step 5: Authentication & Networking

  1. Authentication:
    • Choose System-assigned Managed Identity for security.
    • Enable RBAC (Role-Based Access Control) for access control.
  2. Networking:
    • Select Azure CNI (Advanced) for better networking control.
    • Keep HTTP Application Routing disabled (unless needed).

βœ… Step 6: Review & Create

  1. Click “Review + Create”.
  2. Verify all configurations.
  3. Click “Create” (Deployment may take 5-10 minutes).

πŸš€ Step 7: Connect to Your AKS Cluster

Once deployed, you need to connect using Azure CLI.

  1. Install Azure CLI (if not installed)
    az login
  2. Get AKS Credentials
    az aks get-credentials –resource-group MyResourceGroup –name myAKSCluster
  3. Verify Cluster Connection
    kubectl get nodes
  4. If it returns a list of nodes, your cluster is working! πŸŽ‰

πŸ“¦ Step 8: Deploy an Application to AKS

Let’s deploy a simple NGINX web server to AKS.

1. Create a deployment.yaml file:

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

2. Deploy it using:
kubectl apply -f deployment.yaml

3. Verify deployment:
kubectl get pods

4. You should see running pods! πŸŽ‰


🌐 Step 9: Expose Your App to the Internet

1. Create a service to expose the app:
apiVersion: v1

kind: Service

metadata:

  name: nginx-service

spec:

  selector:

    app: nginx

  ports:

    – protocol: TCP

      port: 80

      targetPort: 80

  type: LoadBalancer

2. Apply the service:
kubectl apply -f service.yaml

3. Get the external IP:
kubectl get service nginx-service

4. Open the EXTERNAL-IP in a browser to see the running app! πŸŽ‰


πŸ› οΈ Step 10: Scale & Manage the Cluster

  1. Scale the deployment:
    kubectl scale deployment nginx-deployment –replicas=5
  2. Monitor logs:
    kubectl logs -f <pod-name>
  3. Delete the deployment (if needed):
    kubectl delete deployment nginx-deployment

πŸ—‘οΈ Step 11: Delete the AKS Cluster (If Not Needed)

To avoid costs, delete the cluster:

az aks delete –resource-group MyResourceGroup –name myAKSCluster –yes –no-wait

Similiar Posts

View All AZURE

Download Syllabus

Fill up the form below to download the syllabus