I am trying to implement CI/CD pipeline for my APIs on AKS. i have successfully configured the CI and CD pipelines which works quite smoothly, now i have 2 environments named Prod and Slot to enable 0 down time.
I found the blue/green deployment
method. And in my CD pipeline i am trying to set the current slot and pass it to the helm upgrade command in the next step
currentSlot=`(helm --client-only get values --all api-poi | grep -Po 'productionSlot: \K.*')`
if [ "$currentSlot" == "blue" ]; then
newSlot="green"
else
newSlot="blue"
fi
but it always set the newslot as empty. what could be the reason?
$(newSlot).enabled=true
Try with Azure CLI command instead of Bash script with the az aks get-credentials --name
involved.
Alternate CLI command would be
az aks get-credentials --name $(AKSClusterName) --resource-group $(AKSResourceGroup)
currentSlot=$(helm get values --all $(chartName) | grep -oP '(?<=productionSlot: ).*')
if [ "$currentSlot" == "blue" ]; then
newSlot="green"
else
newSlot="blue"
fi
you need to set those AKSClusterName,AKSResourceGroup,chartName values in the pipeline or hard code them