Advanced End-to-End DevSecOps Kubernetes Three-Tier Project Using AWS EKS, ArgoCD, Prometheus, Grafa
Advanced End-to-End DevSecOps Kubernetes Three-Tier Project Using AWS EKS, ArgoCD, Prometheus, Grafa
571 4
Project Introduction:
Welcome to the End-to-End DevSecOps Kubernetes Project guide! In this
comprehensive project, we will walk through the process of setting up a
robust Three-Tier architecture on AWS using Kubernetes, DevOps best
practices, and security measures. This project aims to provide hands-on
experience in deploying, securing, and monitoring a scalable application
environment.
Project Overview:
In this project, we will cover the following key aspects:
1. IAM User Setup: Create an IAM user on AWS with the necessary
permissions to facilitate deployment and management activities.
2. Infrastructure as Code (IaC): Use Terraform and AWS CLI to set up the
Jenkins server (EC2 instance) on AWS.
10. Monitoring Setup: Implement monitoring for the EKS cluster using
Helm, Prometheus, and Grafana.
Prerequisites:
Before starting the project, ensure you have the following prerequisites:
Now, Select your created user then click on Security credentials and
generate access key by clicking on Create access key.
Select the Command Line Interface (CLI) then select the checkmark for the
confirmation and click on Next.
Here, you will see that you got the credentials and also you can download the
CSV file for the future.
Step 2: We will install Terraform & AWS CLI to deploy our Jenkins
Server(EC2) on AWS.
Install & Configure Terraform and AWS CLI on your local machine to create
Jenkins Server on AWS Cloud
Configure Terraform
Edit the file /etc/environment using the below command add the highlighted
lines and add your keys in the blur space.
After doing the changes, restart your machine to reflect the changes of your
environment variables.
aws configure
Now, you have to replace the Pem File name as you have some other name
for your Pem file. To provide the Pem file name that is already created on
AWS
terraform init
terraform validate
Run the below command to get the blueprint of what kind of AWS services
will be created.
Now, run the below command to create the infrastructure on AWS Cloud
which will take 3 to 4 minutes maximum
jenkins --version
docker --version
docker ps
terraform --version
kubectl version
aws --version
trivy --version
eksctl --version
Now, we have to configure Jenkins. So, copy the public IP of your Jenkins
Server and paste it on your favorite browser with an 8080 port.
Go to Manage Jenkins
Click on Plugins
Select the Available plugins install the following plugins and click on Install
AWS Credentials
Once, both the plugins are installed, restart your Jenkins service by checking
the Restart Jenkins option.
Click on global.
Select AWS Credentials as Kind and add the ID same as shown in the below
snippet except for your AWS Access Key & Secret Access key and click on
Create.
So, add the username and personal access token of your GitHub account.
eksctl create cluster --name Three-Tier-K8s-EKS-Cluster --region us-east-1 --node-type t2.medium --nodes-min 2 --nodes-max 2
aws eks update-kubeconfig --region us-east-1 --name Three-Tier-K8s-EKS-Cluster
Once your cluster is created, you can validate whether your nodes are ready
or not by the below command
curl -O https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.5.4/docs/install/iam_policy.json
After 2 minutes, run the command below to check whether your pods are
running or not.
Select the Private option to provide the repository and click on Save.
As you know, Our two ECR repositories are private. So, when we try to push
images to the ECR Repos it will give us the error Imagepullerror.
To get rid of this error, we will create a secret for our ECR Repo by the below
command and then, we will add this secret to the deployment file.
Note: The Secrets are coming from the .docker/config.json file which is
created while login the ECR in the earlier steps
Now, expose the argoCD server as LoadBalancer using the below command
You can validate whether the Load Balancer is created or not by going to the
AWS Console
To access the argoCD, copy the LoadBalancer DNS and hit on your favorite
browser.
Click on Advanced.
Now, we need to get the password for our argoCD server to perform the
deployment.
To do that, we have a pre-requisite which is jq. Install it by the command
below.
Enter the username and password in argoCD and click on SIGN IN.
Click on Generate
Click on Create
Provide the name of your project and in the URL, provide the Jenkins server
public IP with port 8080 add sonarqube-webhook in the suffix, and click on
Create.
http://<jenkins-server-public-ip>:8080/sonarqube-webhook/
Click on Manually.
Click on Locally.
After performing the above steps, you will get the command which you can
see in the below snippet.
Now, use the command in the Jenkins Frontend Pipeline where Code Quality
Analysis will be performed.
Provide the name of your project name and click on Set up.
Click on Locally.
After performing the above steps, you will get the command which you can
see in the below snippet.
Now, use the command in the Jenkins Backend Pipeline where Code Quality
Analysis will be performed.
Select the kind as Secret text paste your token in Secret and keep other
things as it is.
Click on Create
Now, we have to store the GitHub Personal access token to push the
deployment file which will be modified in the pipeline itself for the ECR
image.
Select the kind as Secret text and paste your GitHub Personal access
token(not password) in Secret and keep other things as it is.
Click on Create
Note: If you haven’t generated your token then, you have it generated first
then paste it into the Jenkins
Select the kind as Secret text paste your AWS Account ID in Secret and keep
other things as it is.
Click on Create
Now, we need to provide our ECR image name for frontend which is
frontend only.
Select the kind as Secret text paste your frontend repo name in Secret and
keep other things as it is.
Click on Create
Now, we need to provide our ECR image name for the backend which is
backend only.
Select the kind as Secret text, paste your backend repo name in Secret, and
keep other things as it is.
Click on Create
Step 10: Install the required plugins and configure the plugins to
deploy our Three-Tier Application
Install the following plugins by going to Dashboard -> Manage Jenkins ->
Plugins -> Available Plugins
Docker
Docker Commons
Docker Pipeline
Docker API
docker-build-step
Eclipse Temurin installer
NodeJS
OWASP Dependency-Check
SonarQube Scanner
Search for jdk and provide the configuration like the below snippet.
Search for the sonarqube scanner and provide the configuration like the
below snippet.
Search for node and provide the configuration like the below snippet.
Now, we will configure the OWASP Dependency check
Search for Dependency-Check and provide the configuration like the below
snippet.
Search for docker and provide the configuration like the below snippet.
Provide the name as it is, then in the Server URL copy the sonarqube public
IP (same as Jenkins) with port 9000 select the sonar token that we have
added recently, and click on Apply & Save.
Now, we are ready to create our Jenkins Pipeline to deploy our Backend
Code.
Go to Jenkins Dashboard
https://github.com/AmanPathak-DevOps/End-to-End-Kubernetes-Three-Tier-
DevSecOps-Project/blob/master/Jenkins-Pipeline-Code/Jenkinsfile-Backend
Now, we are ready to create our Jenkins Pipeline to deploy our Frontend
Code.
Go to Jenkins Dashboard
https://github.com/AmanPathak-DevOps/End-to-End-Kubernetes-Three-Tier-
DevSecOps-Project/blob/master/Jenkins-Pipeline-Code/Jenkinsfile-Frontend
Setup 10: We will set up the Monitoring for our EKS Cluster. We can monitor
the Cluster Specifications and other necessary things.
Now, we need to access our Prometheus and Grafana consoles from outside
of the cluster.
Now, if you list again the service then, you will see the LoadBalancers DNS
names
Copy the ALB DNS of Grafana and paste it into your favorite browser.
The username will be admin and the password will be prom-operator for
your Grafana LogIn.
Select Prometheus
Click on Dashboard.
Once you click on Dashboard. You will see a lot of Kubernetes components
monitoring.
Select the data source that you have created earlier and click on Import.
Now, provide the repository name where your Manifests files are present.
Provide the username and GitHub Personal Access token and click on
CONNECT.
Provide the details as it is provided in the below snippet and scroll down.
Select the same repository that you configured in the earlier step.
In the Path, provide the location where your Manifest files are presented
and provide other things as shown in the below screenshot.
Click on CREATE.
Provide the details as it is provided in the below snippet and scroll down.
Select the same repository that you configured in the earlier step.
In the Path, provide the location where your Manifest files are presented
and provide other things as shown in the below screenshot.
Click on CREATE.
Provide the details as it is provided in the below snippet and scroll down.
Select the same repository that you configured in the earlier step.
In the Path, provide the location where your Manifest files are presented
and provide other things as shown in the below screenshot.
Click on CREATE.
Provide the details as it is provided in the below snippet and scroll down.
Select the same repository that you configured in the earlier step.
In the Path, provide the location where your Manifest files are presented
and provide other things as shown in the below screenshot.
Click on CREATE.
You can check out the load balancer named with k8s-three.
Now, Copy the ALB-DNS and go to your Domain Provider in my case porkbun
is the domain provider.
Go to DNS and add a CNAME type with hostname backend then add your
ALB in the Answer and click on Save
Now, hit your subdomain after 2 to 3 minutes in your browser to see the
magic.
Now, you can see your Grafana Dashboard to view the EKS data such as pods,
namespace, deployments, etc.
Conclusion:
In this comprehensive DevSecOps Kubernetes project, we successfully:
Feel free to reach out to me, if you have any other queries.
Happy Learning!
Stackademic
Thank you for reading until the end. Before you go:
571 4
Written by Aman Pathak Follow
DevOps Engineer | AWS Community Builder | AWS Certified | Azure | Terraform | Docker |
Ansible | CI/CD Jenkins | Oracle Certified
411 4 1.5K 25
917 14 208
208 583 9
Lists
Productivity
237 stories · 290 saves
3.9K 51 1.2K 8
3.1K 34 25 2
Help Status About Careers Blog Privacy Terms Text to speech Teams