Delivering modern cloud-native applications with open source technologies on Azure Kubernetes Service
This workshop will guide you through building Continuous Integration (CI) and Continuous Deployment (CD) pipelines with Azure DevOps for use with Azure Kubernetes Service. The pipeline will utilize Azure Container Registry to build the images and Helm for application updating.
The general workflow/result will be as follows:
Create a Azure DevOps organization/account. Follow the steps here: https://docs.microsoft.com/en-us/azure/devops/user-guide/sign-up-invite-teammates?view=vsts
Create New Project in Azure DevOps
On the next screen, click “Repos” and then “import a repository”
Enter https://github.com/Azure/kubernetes-hackfest
for the Clone URL and click “Import”
In Azure DevOps, click on “Pipelines” on the left menu and then click “Builds”
Click the “New pipeline” button
Azure DevOps pipelines now defaults to the yaml based editing experience. The following steps assume classic mode, so you should select ‘Use the classic editor’ as shown below.
Azure Repos Git
and ensure it is pointing to your newly built repo (this is the default)
Note that we are using the master branch here. Normally we would use other branches and PR’s. For simplicity, we are using master just for this lab.
Select to “start with an Empty job”
Leave the name as “kubernetes-hackfest-CI”
Make sure the Agent pool is set to ‘Azure Pipelines’ and the Agent Specification is set to use the ‘ubuntu-1804’
Click the plus sign by “Agent job 1” to add a task
Search tasks for “Azure” and add the Azure CLI task
Click on the Azure CLI task and choose your Azure subscription and Authorize
For “Script Location” choose “Inline script” and enter the following (be sure to replace the ACR name with yours).
Note: We are creating a dynamic image tag using our build ID from Azure DevOps.
# set your Azure Container Registry name below
export ACRNAME=
export IMAGETAG=azuredevops-$(Build.BuildId)
az acr build -t hackfest/data-api:$IMAGETAG -r $ACRNAME --no-logs ./app/data-api
az acr build -t hackfest/flights-api:$IMAGETAG -r $ACRNAME --no-logs ./app/flights-api
az acr build -t hackfest/quakes-api:$IMAGETAG -r $ACRNAME --no-logs ./app/quakes-api
az acr build -t hackfest/weather-api:$IMAGETAG -r $ACRNAME --no-logs ./app/weather-api
az acr build -t hackfest/service-tracker-ui:$IMAGETAG -r $ACRNAME --no-logs ./app/service-tracker-ui
Add a final task to “Agent job 1” and search for “Publish Pipeline Artifact”. Use “charts” for the “Artifact name” and browse to the charts folder for the “File or directory path”.
Test this by clicking “Save & queue” and providing a comment
Click on “Builds” to check result. It can take a bit of time for all of the steps to complete.
In the deployment pipeline, we will create a Helm task to update our application.
> Note: To save time, we will only deploy the service-tracker-ui application in this lab.
In Azure DevOps, click on “Pipelines” on the left menu and then click “Releases”
Click the “New pipeline” button
Select to “start with an Empty job”
Name the pipeline “AKS Helm Deploy” (it will default to “New release pipeline”)
Click on “+ Add” next to Artifacts
In “Source (build pipeline)”, select the build we created earlier (should be named “kubernetes-hackfest-CI”)
Click on the lightning bolt next to the Artifact we just created and enable “Continuous deployment trigger”
Click on “Stage 1” in the Stages box.
Name the stage “dev”
Click on “1 job, 0 task” to view stage tasks
Click on “Agent job” and change the Agent pool to “Azure Pipelines” and the Agent Specification to “ubuntu-1804” in the drop down
On the Agent job, click the “+” to add a Task
Search for “helm” and add the task called “Helm Tool Installer” as first task. Click Add
Change the version for the helm install to
3.1.1
Next, Search for “helm” and add the task called “Package and deploy Helm charts”. Click Add
Click on the task (named “helm ls”) to configure all of the settings for the release
service-tracker-ui
deploy.acrServer=acrhackfestbrian13932.azurecr.io,deploy.imageTag=azuredevops-$(Build.BuildId)
In Azure DevOps, click on Pipelines, and select “Run Pipeline” from the menu of the kubernetes-hackfest-CI build pipeline
Monitor the builds and wait for the build to complete
The release will automatically start when the build is complete (be patient, this can take some time). Review the results as it is complete.
Validate that your newly built image was deployed in your AKS cluster. Eg - kubectl describe pod service-tracker-ui-<pod id> -n hackfest
Now kick-off the full CI/CD pipeline by making an edit to the service-tracker-ui frontend code in the Azure DevOps code repo.