This project deploys two applications to the same kubernetes cluster using IaC and CI/CD approach.
The following tools where used for this project which are:
-
Kubernetes
: an open-source container orchestration system for automating software deployment, scaling, and management. -
Kubectl
: a tool used to interact with kubernetes clusters -
CircleCI
: Is a cloud based CI/CD pipeline tool -
Terraform
: Is a cloud agnostic IaC tool used to provision of the app -
Prometheus
: Is a tool used for monitoring and alerting incase things starts get weary -
Grafana
: Is an open source analytics and interactive visualization web application used to visualize performance metrics -
AWS
: Is the cloud provider used for this project -
Docker
andDockerhub
-
Git
andGithub
In the terraform folder, we have another folder called backend, this folder contains the configuration of where the terraform state file will be stored. I created an S3 bucket to store the file and an AWS DynamoDB to ensure state locking and consistency of the state file.
The bucket and DynamoDB set up by the CircleCI Pipeline
In the same terraform folder, there is a folder called infrastructure, the files in the folder has the configuration to provision an EKS cluster, create the VPC, set up an IAM role to secure access to who interacts with the cluster and other networking dependencies like lb and security group.
Also I setted up AWS Cloudwatch for logging and Metrics of the EKS cluster
This folder contains the deployment files which I used to setup domain name for the web application and the microservice application and also the kubernetes manifest file (```complete-demo.yaml```) used to install the apllication on the cluster and exposing of ports used in the various applications.
In the microservices application, I setted up a service called front-end and gave it a ```LoadBalancer```, also the web application I dockerized it and pushed it to dockerhub built from Nginx image and connected it to a ```mysql-db``` also exposing the service ```3306```
In the udagram-app folder, there is a dockerfile used to dockerize the application and push to docker through the pipeline
CI/CD was implemented for this project using CircleCI
. The code for the CI/CD pipeline can be found in the .circleci
folder which contains a config.yml
file containing the code for the CI/CD pipeline. The CI/CD pipeline has six jobs;
-
build_docker_image
: this job builds the docker image for the portfolio app and pushes the built image to dockerhub image repository. -
create_backend_state_store
: this job applies the terraform script(s) in theterraform-files/backend
directory. This will create and S3 backend and DynamoDB for storing and locking state. This job will only execute if thebackend
branch of the repository is triggered. -
create_infrastructure
: this job applies the terraform script(s) in theterraform-files/infrastructure
directory. This will create the network infrastructure as earlier stated. -
deploy_applications
: this job applies the terraform script(s) in theterraform-files/deployment
directory. This will deploy the two applications to the EKS cluster created in the previous job. It also creates two subdomains and maps the loadbalancers from the two applications to the subdomains. -
configure_monitoring
: this job applies the terraform script(s) in theterraform-files/monitoring
directory. This will deploy prometheus and grafana to the cluster. -
destroy_everything
: this job will destroy the whole deployment and infrastructure by executingterraform destroy --auto-approve
in theterraform-files/monitoring
,terraform-files/deployment
andterraform-files/infrastructure
directories. This job will only execute if thedestroy
branch of the repository is triggered.
The images shows the successful execution of the jobs in the CI/CD pipeline after it was triggered.
In the terraform, another folder called monitoring, has a series of yaml files (kubernetes manifest files) used to setup monitoring and alerting tools such as prometheus and grafana in the kubernetes. Using the cloud watch logs to analyze system performance/
In the grafana-svc and prometheus-svc files I changed NodePort
to `LoadBalancer`
- Prometheus Access Point: Prometheus url
- Grafana Access Point: Grafana url
I used CircleCI's envrionment variable to store sensitive data