Azure Kubernetes Service (AKS) is a managed container orchestration service, based on the open source Kubernetes system, which is available on the Microsoft Azure public cloud. AKS allows you to quickly deploy a production ready Kubernetes cluster in Azure, deploy and manage containerized applications more easily with a fully managed Kubernetes service. We will see how to create AKS cluster in Azure cloud using Terraform.
AKS cluster can be created by many ways as mentioned below:
Creating an AKS resource with Terraform is incredibly easy, it only requires a single resource azurerm_kubernetes_cluster and in this post, we are going to walk through the necessary steps to create this with Terraform. We will create ACR and create a role with ACRpull assignment as well
Once the deployment is created, use kubectl to check on the deployments by running this command:
kubectl get deployments
To see the list of pods
kubectl get pods
Perform cleanup by deleting the AKS cluster
To avoid Azure charges, you should clean up unneeded resources. When the cluster is no longer needed, use terraform destroy command to remove the resource group, AKS cluster service, and all related resources.
We are going to learn how to Automate build and deploy of Springboot Microservices App into Azure Kubernetes Cluster(AKS) using Helm and Jenkins pipeline.
Sample springboot App Code:
I have created a sample Springboot App setup in GitHub. Click here to access code base in GitHub.
Jenkins pipeline will:
- Automate maven build(jar) using Jenkins - Automate Docker image creation - Automate Docker image upload into Azure container registry - Automate Springboot docker container Deployments to Azure Kubernetes Cluster using Helm charts
sh "helm upgrade first --install mychart --namespace helm-deployment --set image.tag=$BUILD_NUMBER"
}
}
}
}
}
Step # 5 - Build the pipeline
Step # 6 - Verify deployments in AKS
Execute the below command to list the helm deployments:
helm ls -n helm-deployment
kubectl get pods -n helm-deployment
kubectl get services -n helm-deployment
Steps # 7 - Access Springboot App Deployed in AKS cluster
Once deployment is successful, go to browser and enter above load balancer URL mentioned above
You should see page like below:
Clean up the Cluster:
To avoid charges from Azure, you should clean up unneeded resources, use az group delete command to remove the resource group, and all related resources in that group.
az group delete --name resource-group-name --yes --no-wait
We are going to learn how to deploy Springboot Microservices Docker container into Azure Kubernetes Cluster(AKS) using Helm and Azure pipelines.
Sample springboot App Code:
I have created a sample Springboot App setup in GitHub. Click here to access code base in GitHub.
Watch steps in YouTube channel:
What is Helm?
Helm is a package manager for Kubernetes. Helm is the K8s equivalent of yum or apt. It accomplishes the same goals as Linux system package managers like APT or YUM: managing the installation of applications and dependencies behind the scenes and hiding the complexity from the user.
Helm Charts
Helm uses a packaging format called Charts.A Helm Chart is a collection of files that describe a set of Kubernetes resources.Helm Charts helps you define, install, and upgrade even the most complex Kubernetes application. Charts are easy to create, version, share, and publish.
Implementation steps:
Create a resource group, AKS cluster and Azure container registry
Provide pull access for AKS to pull image from ACR
Create a namespace for helm deployment
Create a helm chart for spring boot app
Create a build pipeline to automate docker image
Customize pipeline with helm package tasks
Create a release pipeline
Customize pipeline with helm upgrade tasks
Run the pipeline to deploy springboot app into AKS
If you see any errors after deploying the pods, you can check the pod logs.
kubectl describe pod <pod_name> -n helm-deployment
Go to the browser enter http://localhost:8080
You should see below web page.
Clean up Resources
Let us see how to clean up the resources that were created. We can use az group delete command to remove the resource group, AKS cluster, and all related resources.