This is the last part in the series “Automating container deployment on AKS using Azure DevOps”. So far we have automated the creation of ACR and AKS, built and pushed the container to the Azure Container Registry.
In this post, we’ll create a release pipeline that will pull the container from ACR and deploy it on AKS. We’ll use the kubectl apply command to perform this action.
In order to pull images from ACR, the agentpool SP of AKS needs to have AcrPull rights. Once that’s done, it’s simply a matter of passing the weatherinfoapi-deploy.yml file that the build published to the kubectl apply command.
Create a new Release pipeline in Azure DevOps. For the template, select Deploy to a Kubernetes cluster. Select the latest version of your build pipeline as the source for the Artifact.
Pipeline Tasks
kubectl
Create a Azure Subscription service connection. Set the Command as apply. Check Use Configuration files. Select the kubernetes manifest file from the linked artifact.
Once you save and run the pipeline, the deployment, pod, and service will be created. The image will be pulled from ACR and deployed in AKS.
Post deployment checks
Connect the AKS cluster from your desktop using Azure CLI.
az aks get-credentials --resource-group <resource group name> --name <cluster name>
Get all deployments from the connected cluster.
kubectl get deployment
Get all pods using the below command. You can check whether the pod is ready and its status. If the status says Ready, then the pod was created successfully.
kubectl get pods
If you find that the pod is stuck in ContainerCreating status, you can use the below command to troubleshoot.
kubectl describe pods <pod name>
Finally, use the below command to list all the services. The service that you created will have an external IP address assigned. Using that IP address you can invoke your API.
kubectl get services
Hi great reading your ppost
LikeLike