Cloud-DevOps-assignment
In this assigment I used the Microsoft Azure cloud resources to carry out the operations that I was required to carry out. This is the workflow diagram of the assisgment
Note: The Deployment files and YAML pipelines that are screenshot in this writeup are in the repository, you can check them out.
Tools used:
Git and Azure Git Repos – Source Code Management and Version control system
Docker – Application Containerization system
Azure Container Registry – Managing container images
DockerHub - Sharing container images
Azure Kubernetes Service - Managed container workloads and services
Azure Pipeline - Continuous Integration (CI) and Continuous Delivery (CD)
Datadog – Metrics collection and monitoring.
React-and-Spring-data-rest
Deploy a pipeline to build, test and push the docker image to Azure Container Registry.
As requested, that the pipeline should build, test and push the docker image to a repository. The pipeline built and pushed the Docker images (Front-end and Back-end) to Azure Container Registry known as abimbolacontainerregistry as seen below.
The pipeline below built and pushed the front-end Docker image to the Azure Container Registry.
The Docker image for the front-end app was successfully built and pushed to the Azure Container Registry as seen in the screenshot below
The Docker image is in the Azure repository, the image could also be pushed to DockerHub and other container image repositories. The pipeline below built and pushed the back-end Docker image to the Azure Container Registry
The Docker image for the back-end app was successfully built and pushed to the Azure Container Registry as seen in the screenshot below
The Docker images can be seen in the repository.
Deploy the infrastructure using Infrastructure as Code (Terraform)
I understand that you would like the deployment pipelines to deploy the applications across different environments on the target infrastructure, however, we would first need to build the target infrastructure, in this assignment I would be using Terraform as the Infrastructure as Code (IaC) to deploy the target Infrastructure.
The target Infrastructure would be a Managed Service known as (Azure Kubernetes Service). I used the below pipeline to deploy the Azure Kubernetes Service cluster
The Azure Kubernetes Service cluster screenshot can be seen below
The next line of action is to deploy the applications across different environments on the target infrastructure
I created a secret for the imagepullsecret and MySQL database using the YAML file below. This was done from the terminal, this will allow authentication to the repository and the MySQL database.
Deploying the front-end application using the frontend docker image in ACR, I used this YAML pipeline
The front-end was successfully deployed
Front-end application is deployed to the Azure Kubernetes Cluster as seen below.
The front-end application can be accessed using the load balancer IP address and port 8080, in the deployment YAML file, there is a service that exposed the deployment with type=LoadBalancer
I created a scaling policy that makes the infrastructure scale automatically.
When the CPUs of the nodes in the Kubernetes Cluster gets to 70% threshold for 10 minutes, the node scales out by 1 automatically, also, if the CPUs of the cluster get to below the average threshold, it scales down the nodes.
Deploying the back-end application
Before deploying the back-end application, I first deployed a storage class to the Kubernetes cluster, then created the persisted volume claim, lastly, I deployed the MySQL database to consume the persistent volume claim and ensure that the data in the database are persistent. Once this is done the back-end application would make use of the MySQL database.
See below Storage class and persistent volume claim YAML file
I deployed the Storage Class and Persistent Volume Claim from the terminal
Deploying the MySQL database, I used this YAML pipeline
Database created successfully
MySQL database deployed to Kubernetes cluster as a deployment
Persistent volume claim to persist the data in MySQL database bound successfully
Deploying the back-end application using the backend docker image in ACR, I used this YAML pipeline
The MySQL environment variables was used to deploy the backend application as it can be seen in the deployment file.
Monitoring the Infrastructure
Datadog can help you get full visibility into your AKS deployment by collecting metrics, distributed request traces, and logs from Kubernetes, Azure, and every service running in your container infrastructure. To start monitoring AKS with Datadog, all you need to do is configure the integrations for Kubernetes and Azure. Deploy the containerized Datadog Agent as a DaemonSet within your AKS cluster using the Helm chart.
Install Datadog into Kubernetes using Helm chart
API_KEY=""
helm repo add datadog https://helm.datadoghq.com
helm install datadog --set datadog.site='datadoghq.com'
--set datadog.apiKey=$API_KEY --set datadog.apm.enabled=true
datadog/datadog
The nodes in the kubernetes cluster can be seen below
The Datadog agent was deployed as a Daemonset, the agent can be seen in the Datadog portal
The agents represent the node running in the Kubernetes cluster, once an agent is selected you will be able to see the properties of the node in the cluster as you can see in the below screenshot.
Create a dashboard and start monitoring the cluster
Terraform Pipeline to clean up the infastructure
This is a Public repository, to fork kindly select FORK and you have it.
Thank You