Saurabh Mathuria
4 min readJan 18, 2024

Azure DevOps Pipelines for Azure Kubernetes Service with Classic Editor

What is AKS:
Azure Kubernetes Service (AKS) is a managed Kubernetes service provided by Microsoft Azure. It simplifies deploying, managing, and scaling containerized applications using Kubernetes, an open-source platform designed to automate deploying, scaling, and operating application containers.

What is CI/CD:
Continuous Integration (CI) and Continuous Deployment (CD) are practices used in software development to automate the process of testing, building, and deploying applications.

  • Continuous Integration (CI): It frequently integrates code changes into a shared repository. Each integration triggers an automated build and test process to detect problems early.
  • Continuous Deployment (CD): It automates the deployment of applications to selected environments after passing the CI process. CD ensures that the code changes, once validated, are automatically pushed to production or staging

Environments.

Prerequisites:

  • Azure DevOps Account: Access to an Azure DevOps organization and project.
  • Azure Subscription: Access to Azure resources (AKS, ACR).
  • Source Code: Code repository (e.g., Git) for your application.

Create a Resource Group on the Azure Portal

Create a container registry (ACR)

Assign Role with the help of IAM

Create Azure Kubernetes Service (AKS)

Assign a Specific role as per your requirement

Steps to Create a CI/CD Pipeline for AKS using Azure DevOps:

Steps:

1. Set Up Service Connection:

  • Create a service connection in Azure DevOps to link your DevOps project to your Azure subscription. This connection will allow interaction with Azure services like AKS and ACR.

2. Create a CI Pipeline:

  • Define CI Trigger:
  • Create a new pipeline in Azure DevOps and link it to your source code repository.
  • Set triggers for the pipeline to execute on code commits or specific branch updates.
  • Build and Push Container Image:
  • Add build tasks to your CI pipeline to build the container image from your application code.
  • Docker push tasks to push the built image to your Azure Container Registry (ACR).
  • Ensure you include the necessary authentication (service principal, credentials) to access ACR.

3. Create a Release Pipeline:

  • Define Release Trigger:
  • Create a new release pipeline in Azure DevOps.
  • Set triggers for the release pipeline to be initiated upon successful CI build completion or specific artifact creation.
  • Configure AKS Deployment:
  • Add stages to your release pipeline for deploying to AKS.
  • Use Kubernetes deployment tasks or Helm charts to define deployment steps.
  • Configure the task to pull the container image from ACR and deploy it to your AKS cluster.
  • Provide necessary details like AKS connection, namespace, and the image location in ACR.

Create Repository

First need a Docker file, Manifest file:

Create a Continuous integration Pipeline (CI)

First, select agent

Second Select the Repository and Branch

First task add Docker build task:

Second task add docker push task for (Azure Container Registry)

Third task add Copy Artifacts file

Fourth task Add Publish Artifact

Now create Continuous Deployment (CD)

Click on Release -> Click on new

Add Artifacts

Add stages in the deployment task:

First Select agent:

Add the first task for deployment (select Manifests files)

Click on Save and Create Release

Thank you for reading. Stay inspired, stay curious. Until next time!
Linkedin: https://www.linkedin.com/in/saurabh-mathuria-80553521b/