Description

Hands-on Challenge Day - Deploying a Web Application on Kubernetes in Azure

Introduction

What is Kubernetes?

Kubernetes, often abbreviated as K8s, is an open-source container orchestration platform that automates the deployment, scaling, and management of containerized applications. It groups containers that make up an application into logical units for easy management and discovery.

Why Kubernetes on Azure?

Azure Kubernetes Service (AKS) provides a managed Kubernetes service that reduces the complexity of deploying and managing Kubernetes clusters, offering easy scaling, self-healing, load balancing, and automated updates. It's an ideal platform for deploying containerized applications with all the benefits of cloud computing.

Challenge Scenario

TechSolutions Inc., a software development company, has developed a new web application designed to streamline project management tasks. To meet their scalability and reliability needs, they've decided to deploy this application on Kubernetes in Azure. This move aligns with their goal to modernize their infrastructure and embrace cloud-native technologies.

Problem Statement: TechSolutions Inc. needs a scalable and resilient deployment solution for their new web application to ensure it can handle varying loads and provide a seamless user experience.

Your Mission: Deploy TechSolutions Inc.'s web application on Azure Kubernetes Service (AKS). The deployment should ensure the application is scalable, secure, and easily accessible.

Challenge: Deploying a Web Application on AKS

Requirements:

  1. Azure Account: Access to a Microsoft Azure account.
  2. Web Application: A simple Python Flask web application.

Steps:

  1. Set Up Azure Kubernetes Service:

    az aks create --resource-group myResourceGroup --name myAKSCluster --node-count 2 --enable-addons monitoring --generate-ssh-keys
    
    
  2. Configure kubectl:

    az aks get-credentials --resource-group myResourceGroup --name myAKSCluster
    
    
  3. Prepare the Web Application:

    **app.py:**

    from flask import Flask
    app = Flask(__name__)
    
    @app.route('/')
    def hello_world():
        return 'Hello, Kubernetes on Azure!'
    
    if __name__ == '__main__':
        app.run(debug=True, host='0.0.0.0', port=5000)
    
    

    Dockerfile:

    FROM python:3.8-slim
    WORKDIR /app
    COPY . /app
    RUN pip install Flask
    EXPOSE 5000
    CMD ["python", "app.py"]
    
    
  4. Deploy the Application to AKS:

    deployment.yaml:

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: flask-app
    spec:
      replicas: 2
      selector:
        matchLabels:
          app: flask
      template:
        metadata:
          labels:
            app: flask
        spec:
          containers:
          - name: flask
            image: <your-docker-image>
            ports:
            - containerPort: 5000
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: flask-app-service
    spec:
      type: LoadBalancer
      ports:
      - port: 80
        targetPort: 5000
      selector:
        app: flask
    
    
    kubectl apply -f deployment.yaml