Role of each tool
Azure Repos serves as the source control system, while Azure Pipelines functions as the build system. CAEPE takes charge of deploying and promoting releases between environments. The diagram below illustrates how these tools work together.
Azure DevOps Pre-requisites
Part 1: CAEPE features for simplified deployment
Confident Delivery
Confident Delivery is a concept within CAEPE. It refers to pre and post-deployment testing that ensures your deployments are optimized when it comes to utilization and performance of your infrastructure. It provides diagnostics that enable you to evaluate variables such as uptime, backup and restore, infrastructure costs and elasticity.
You specify which Confident Delivery features to enable when you set up a new deployment.
Pre-Flight Test
Before we discuss the integration, let’s look at how CAEPE simplifies managing deployments.
Cluster Groups
CAEPE allows the grouping of clusters, enabling a single deployment to multiple clusters with minimal effort, regardless of their locations
Deployment Strategies
Within CAEPE, major deployment strategies can be employed and applied to a cluster group.
Dry Run
Part 2: Setting up the integration between ADO & CAEPE
Now, let’s examine the integration with ADO.
A. Build
Utilize Azure Pipelines to build/test your application code and generate the required artifacts. In your repository, edit the azure-pipelines.yml and add the code below:
name : Build, Test and Push
trigger:
- main
pool:
vmImage: ubuntu-latest
strategy:
matrix:
Python38:
python.version: '3.8'
Python39:
python.version: '3.9'
Python310:
python.version: '3.10'
steps:
- task: UsePythonVersion@0
displayName: Build and test code
inputs:
versionSpec: '$(python.version)'
displayName: 'Use Python $(python.version)'
- script: |
python -m pip install --upgrade pip
pip install -r requirements.txt
displayName: 'Install dependencies'
- script: |
pip install pytest pytest-azurepipelines
pytest
displayName: 'pytest'
- task: Docker@2
displayName: Build and push image to container registry
inputs:
command: buildAndPush
repository: $(imageRepository)
dockerfile: $(dockerfilePath)
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
$(tag)
B. Release
- Add the artifacts
- Create a deploy task with bash script and add the code below:
- Add the CAEPE trigger
Add the CAEPE trigger to your Azure Pipelines workflow to initiate deployments to Kubernetes clusters. ADO will trigger a CAEPE deployment to a selected environment after every build. Configure the action with necessary parameters like application name, version, and target environment. CAEPE provides various options, including CLI, API, or webhooks. I’ve given examples for all options below:
CAEPE CLI
# Write your commands here
set -x
ls -lart ${AGENT_RELEASEDIRECTORY}
ls -lart ${AGENT_RELEASEDIRECTORY}/_caepe-cli-linux-amd64
chmod 755 ${AGENT_RELEASEDIRECTORY}/_caepe-cli-linux-amd64/caepe-cli-linux-amd64
#-- Authenticate
CAEPE_CLIENTID=$(CLIENTID) CAEPE_CLIENTSECRET=$(CLIENTSECRET) ${AGENT_RELEASEDIRECTORY}/_caepe-cli-linux-amd64/caepe-cli-linux-amd64 login --organization $(ORG)
#-- Trigger Deployment
${AGENT_RELEASEDIRECTORY}/_caepe-cli-linux-amd64/caepe-cli-linux-amd64 deployment rollout -d $(DEPNAME) --hostname $(HOST1) --organization $(ORG) --scheme https --debug
CAEPE API
# Write your commands here
set -x
ls -lart ${AGENT_RELEASEDIRECTORY}
ls -lart ${AGENT_RELEASEDIRECTORY}/_caepe-cli-linux-amd64
chmod 755 ${AGENT_RELEASEDIRECTORY}/_caepe-cli-linux-amd64/caepe-cli-linux-amd64
#-- Authenticate
CAEPE_CLIENTID=$(CLIENTID) CAEPE_CLIENTSECRET=$(CLIENTSECRET) ${AGENT_RELEASEDIRECTORY}/_caepe-cli-linux-amd64/caepe-cli-linux-amd64 login --organization $(ORG)
#-- Trigger Deployment
curl -X POST https://www/v2/Deployments -H accept: application/json -H organization: myorg -H Content-Type: application/json -d {"name":"string","description":"string","namespace":"string","cluster":{"clusterName":"string","clusterId":"string"},"application":"string","deploymentType":"standard","postDeployActivities":[{"postDeployActivities":"smoketest"}],"release":{"branch":"string","message":"string"},"accessGroups":[{"name":"string","id":"string"}],"strategy":{"name":"string"},"arguments":[{"key":"string","value":"string","clusterOrGroup":"string"}]}
CAEPE WEBHOOK
# Write your commands here
set -x
ls -lart ${AGENT_RELEASEDIRECTORY}
ls -lart ${AGENT_RELEASEDIRECTORY}/_caepe-cli-linux-amd64
chmod 755 ${AGENT_RELEASEDIRECTORY}/_caepe-cli-linux-amd64/caepe-cli-linux-amd64
#-- Authenticate
CAEPE_CLIENTID=$(CLIENTID) CAEPE_CLIENTSECRET=$(CLIENTSECRET) ${AGENT_RELEASEDIRECTORY}/_caepe-cli-linux-amd64/caepe-cli-linux-amd64 login --organization $(ORG)
#-- Trigger Deployment
curl -H "Content-Type:application/json" -X POST --data "{\"foo\": \"bar\"}" https://hook.caepe.sh/serviceid/trigger/jobid
Conclusion: Streamline Your CI/CD Pipeline with CAEPE and ADO
By following the step-by-step guide provided in this article, seamlessly integrate CAEPE with ADO and leverage their combined capabilities for efficient Kubernetes deployments. This integration significantly streamlines your DevOps workflow and Kubernetes deployments. As a CD tool, CAEPE automates the deployment process, facilitating quicker and more dependable software releases.