We are going to learn how to deploy Springboot Microservices Docker containers into Azure Kubernetes Cluster(AKS) using Azure pipelines. I have created a sample Springboot App setup in GitHub. Click here to access code base in GitHub.
Watch the steps in YouTube Channel:
1. AKS cluster needs to be up running. You can create AKS cluster using any of one of the below options:
- Create AKS cluster in Azure portal directly
- Create AKS cluster using Azure CLI
- Create AKS cluster using Terraform
2. ACR is also setup in Azure cloud.
3. Have Azure DevOps project dashboard in
4. Dockerfile created along with the application source code for springboot App.
5. Make sure AKS has pull access from ACR
6. Modify K8S manifest file per acr, image name for AKS Deployment
Implementation Steps:
Step 1 - Create Azure Build pipeline for building Docker images and uploading into ACR
Step 2 - Create Azure Release pipeline for deploying Springboot Docker containers into AKS
Step 1 - How to create a Azure Build Pipeline
1. Login into your Azure DevOps dashboard
2. Click on Pipelines.
3. Click on New Pipeline
Enter your repo name and branch name where you have stored your source code along with Dockerfile:
Click on Continue. Now choose the template by typing Docker, Select Docker container and Apply.
Now pipeline is created with two tasks already. We need to more tasks:
Let's add Maven build task for building the JAR file.
Click on + icon and type Maven
Let's modify Build an image task.
Select Push an image task
Add a task for Copying YAML file, enter the Kubernetes deployment YAML file -
aks-deploy-from-acr.yaml
Step 2 - How to Create Release pipeline for deploying Docker containers into AKS Cluster
Go to Pipelines --> Click on Releases --> New Release pipeline
Click on Stage 1 and choose a template by selecting
Deploy to a Kubernetes cluster and click on ApplyAdd Replace token task
Click on + to add task, type token and choose replace token task.
Now click on replace token task and Clik on root directory, click on ... dots
select the drop directory from below:
and enter Target file as aks-deploy-from-acr.yaml
Click on kubectl apply
Now Click on New to enter AKS cluster connection info
Choose the Azure subscription and enter Microsoft user credentials.
Select AKS cluster from the drop down, choose default namespace
Now you will see the following tasks are in green to confirm Deployment was successful.
kubectl get deployments
kubectl get pods
kubectl get svc
Now try to access spring boot application running inside AKS cluster by using external IP and port number
Nice! Amazing!
ReplyDelete