Skip to content

Deploying App on AKS Cluster

General Guide

  1. Create an Azure DevOps Organization: Set up a new Azure DevOps organization and project to host the CI/CD pipeline.
  2. Import Code and Set Up the Environment: Import the Python application code repository and configure the environment.
  3. Create Personal Access Token: Generate a Personal Access Token (PAT) for authentication.
  4. Download Self-Hosted Agent: Set up a self-hosted agent on a Linux virtual machine to execute pipeline tasks.
  5. Configure the Agent: Configure the agent to communicate with Azure DevOps.
  6. Create Pipeline Environment: Set up a pipeline environment for Kubernetes.
  7. Create a Service Connection and an ACR: Establish a connection between Azure DevOps and Azure Container Registry (ACR) for image storage.
  8. Update Deployment Image: Update the image reference in the deployment manifest.
  9. Create the CI/CD Pipeline: Define the pipeline in Azure Pipelines YAML file and trigger the build and deployment process.
  10. Access the AKS Cluster: Verify the deployment by accessing the deployed application.

Now, let’s dive into the detailed steps to implement this solution.

Step-by-Step Guide

1. Create an Azure DevOps Organization

  • I have these resources provisioned already.
  • Log in to the Azure portal and create a new Azure DevOps organization and project named ‘MyFirstProject’.

2. Import Code and Set Up the Environment

  • Import the provided Python application code repository into Azure DevOps.
  • Switch to the ‘aks’ branch of the repository.

3. Create Personal Access Token

  • Generate a Personal Access Token (PAT) with full access permissions in Azure DevOps.

4. Download Self-Hosted Agent

  • Navigate to Project Settings in Azure DevOps and download the self-hosted agent.
  • SSH into the lab-VM Linux virtual machine and download the agent using the provided URL.

5. Configure the Agent

  • Run the configuration script on the downloaded agent, providing necessary details such as server URL and PAT for authentication.

6. Create Pipeline Environment

  • In Azure Pipelines, create a new environment named ‘dev’ for Kubernetes.
  • Validate the environment details and create it.

7. Create a Service Connection and an ACR

  • In Project Settings, create a service connection to Azure Container Registry (ACR) for image storage.
  • Configure the connection details and authenticate with ACR.

8. Update Deployment Image

  • Update the image reference in the deployment manifest file to point to the Azure Container Registry (ACR) image.

9. Create the CI/CD Pipeline

  • Define the pipeline configuration in the azure-pipelines.yml file, specifying build and deployment stages.
  • Trigger the pipeline and monitor the build and deployment process in Azure Pipelines.

10. Access the AKS Cluster

  • Verify the deployment by accessing the deployed application through the external IP provided by the AKS cluster.

Reference: https://yourtechie.hashnode.dev/deploying-a-python-app-to-an-aks-cluster-using-azure-pipelines

Leave Your Message