Skip to content

Commit 93e2661

Browse files
authored
Update README.md
1 parent f663d35 commit 93e2661

1 file changed

Lines changed: 269 additions & 1 deletion

File tree

README.md

Lines changed: 269 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,270 @@
1+
# CloudRail Assignment Task: Automate the Deployment and Monitoring of a Web Application Using Open-Source Tools
12

2-
CloudRail_Assignment
3+
#### Things to keep in mind:
4+
- Application has 2 components which Frontend and Backend
5+
- Frontend is based on Angular Framework and is of Node 8 version and Angular Cli Version 1.7.3
6+
- Backend is based on Nodejs and express and is of Node 8 version
7+
- Application also use MongoDB as a Datatbase. I have used MongoDB Atlas Cluster URI.
8+
9+
10+
#### CICD Flow used for the Project :
11+
- Source Code is pushed to Github Repository.
12+
- For Automating Continous Integration , I have used Github Action Workflow which works similar to Jenkins, GitLab CI,etc.
13+
- I have created ci.yml file which has all the Stages and Step. File is located in .github/workflows directory.
14+
- The Stages Constitute stages like : Build, Test & Deploy.
15+
- For Continous Deployment , I have used ArgoCD which is a GitOps Controller and Open Source Tool.
16+
17+
18+
#### Stage 1 in Github Action Workflow : Build & Push
19+
- In this Stage, I am Checking Out the Code Installing Trivy and Setting Up NodeJs Environment.
20+
- Trivy is a free and open source tool to check vulnerabilities and scan containers as well as Images build using Docker.
21+
- Using Docker , I dockerised the Frontend & Backend of the application using Dockerfiles for the respective .
22+
- After Dockerizing the Frontend & backend , Images Are scanned by trivy and pushed to DockerHub Registery.
23+
24+
25+
<img width="1440" alt="Screenshot 2023-06-07 at 12 46 42 AM" src="https://github.com/RohanRusta21/InternetSpeed/assets/110477025/269a8f56-5e39-45a7-8f8f-01f8cd59dc77">
26+
27+
28+
<img width="1440" alt="Screenshot 2023-06-07 at 12 47 15 AM" src="https://github.com/RohanRusta21/InternetSpeed/assets/110477025/6458e51a-aca7-462a-9d39-7aa59b48e701">
29+
30+
31+
#### Stage 2 in Github Action Workflow : Test Frontend & Backend
32+
- In this Stage, I am Testing the Build Dependencies Installed in Frontend & Backend.
33+
- I have Setup the Required Node Verison to install Dependencies and Test.
34+
35+
<img width="1440" alt="Screenshot 2023-06-07 at 12 47 35 AM" src="https://github.com/RohanRusta21/InternetSpeed/assets/110477025/145a420c-8356-45e4-97ab-1c09b3cf8a1d">
36+
37+
38+
<img width="1440" alt="Screenshot 2023-06-07 at 12 47 56 AM" src="https://github.com/RohanRusta21/InternetSpeed/assets/110477025/cdeacae9-edcc-42e5-96e4-20da11eaf05d">
39+
40+
41+
#### Stage 3 in Github Action Workflow : Update Manifest & Deploy Application
42+
- In this Stage, I am updating the YML Manifests with the updated Image build during dockerizing.
43+
- After completing the above 2 stages we are updating the Image version on a different repository specifically maintained to store manifest files used for Kubernetes Cluster.
44+
- After Updating the Deployment.yml for both frontend and backend, I pushed the code with the new commit.
45+
46+
47+
48+
<img width="1440" alt="Screenshot 2023-06-07 at 12 48 21 AM" src="https://github.com/RohanRusta21/InternetSpeed/assets/110477025/a72e3f88-fe78-4ddf-9026-9772d970937f">
49+
50+
51+
52+
<img width="1440" alt="Screenshot 2023-06-07 at 12 45 59 AM" src="https://github.com/RohanRusta21/InternetSpeed/assets/110477025/3600bacf-e7b4-4694-b7ec-6948ad99464c">
53+
54+
55+
56+
# Creating AWS EKS Cluster to deploy Application
57+
58+
#### Pre-requisites:
59+
- an EC2 Instance (Note : If Using Ubuntu EC2 Instance instead of Amazon Linux then Make Sure to have **aws-iam-authenticator** installed.)
60+
61+
62+
#### Article to Install aws-iam-authenticator :
63+
```sh
64+
https://docs.aws.amazon.com/eks/latest/userguide/install-aws-iam-authenticator.html
65+
```
66+
67+
#### AWS EKS Setup
68+
1. Setup kubectl
69+
a. Download kubectl
70+
b. Grant execution permissions to kubectl executable
71+
c. Move kubectl onto /usr/local/bin
72+
d. Test that your kubectl installation was successful
73+
```sh
74+
curl -o kubectl https://amazon-eks.s3.us-west-2.amazonaws.com/1.19.6/2021-01-05/bin/linux/amd64/kubectl
75+
chmod +x ./kubectl
76+
mv ./kubectl /usr/local/bin
77+
kubectl version --short --client
78+
```
79+
2. Setup eksctl
80+
a. Download and extract the latest release
81+
b. Move the extracted binary to /usr/local/bin
82+
c. Test that your eksclt installation was successful
83+
```sh
84+
curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp
85+
sudo mv /tmp/eksctl /usr/local/bin
86+
eksctl version
87+
```
88+
89+
3. Create an IAM Role and attach it to EC2 instance
90+
`Note: create IAM user with programmatic access if your bootstrap system is outside of AWS`
91+
IAM user should have access to
92+
IAM
93+
EC2
94+
VPC
95+
CloudFormation
96+
EKS
97+
Administrator
98+
99+
4. Create your cluster and nodes
100+
```sh
101+
eksctl create cluster --name cluster-name \
102+
--region region-name \
103+
--node-type instance-type \
104+
--nodes-min 2 \
105+
--nodes-max 2 \
106+
--zones <AZ-1>,<AZ-2>
107+
```
108+
109+
110+
# Installing ArgoCD in EKS cluster to make Continous Deployment
111+
112+
#### Prerequisites:
113+
- An existing EKS Cluster.
114+
- AWS Load Balancer Controller Installed.
115+
116+
#### Step 1 : We Create a namespace and Install Manifest for ArgoCD
117+
118+
```sh
119+
kubectl create ns argocd
120+
kubectl apply -f https://raw.githubusercontent.com/argoproj/argo-cd/v2.4.7/manifests/install.yaml -n argocd
121+
```
122+
123+
124+
<img width="1160" alt="Screenshot 2023-06-07 at 12 05 16 AM" src="https://github.com/RohanRusta21/InternetSpeed/assets/110477025/7279ef80-c32e-4d63-8b5f-33297dfc3eb0">
125+
126+
127+
128+
129+
130+
#### Step 2 : Configuring ArgoCD
131+
132+
- Here I have Edited the ArgoCD Server Manifest file from ClusterIP to LoadBalancer to access the ArgoCD UI in Browser.
133+
134+
```sh
135+
kubectl edit svc argocd-server -n argocd
136+
```
137+
138+
![Screenshot 2023-06-07 at 12 06 04 AM](https://github.com/RohanRusta21/InternetSpeed/assets/110477025/5ac500e6-fc85-4e7e-8598-a80b74ead75a)
139+
140+
141+
142+
143+
<img width="1440" alt="Screenshot 2023-06-07 at 12 00 01 AM" src="https://github.com/RohanRusta21/InternetSpeed/assets/110477025/7770e78f-fcd4-4d7c-be55-edba97183bdb">
144+
145+
146+
147+
- Setting Up the manifest repository in ArgoCD.
148+
149+
150+
<img width="1440" alt="Screenshot 2023-06-07 at 12 01 02 AM" src="https://github.com/RohanRusta21/InternetSpeed/assets/110477025/4f320be1-8d28-4214-ac55-f56b215ba290">
151+
152+
153+
154+
155+
156+
<img width="1440" alt="Screenshot 2023-06-07 at 12 03 13 AM" src="https://github.com/RohanRusta21/InternetSpeed/assets/110477025/cdd3f802-1964-4783-8587-a3f4a6a89879">
157+
158+
159+
160+
161+
# Successfully Deployed Our Web Application
162+
163+
- I have used LoadBalancer in my Service yml manifest to access the application outside the cluster
164+
165+
166+
167+
<img width="1440" alt="Screenshot 2023-06-07 at 12 07 01 AM" src="https://github.com/RohanRusta21/InternetSpeed/assets/110477025/ce4a8d9b-6824-4d4b-822d-26adb673f87b">
168+
169+
170+
171+
## Cluster Monitoring using Prometheus & Grafana
172+
173+
Key Components :
174+
175+
- Prometheus server - Processes and stores metrics data
176+
- Alert Manager - Sends alerts to any systems/channels
177+
- Grafana - Visualize scraped data in UI
178+
179+
Pre Requisites :
180+
- EKS Cluster is setup already
181+
- Install Helm
182+
- EC2 instance to access EKS cluster
183+
184+
Installation Steps
185+
```sh
186+
helm repo add stable https://charts.helm.sh/stable
187+
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
188+
helm search repo prometheus-community
189+
kubectl create namespace prometheus
190+
helm install stable prometheus-community/kube-prometheus-stack -n prometheus
191+
kubectl get pods -n prometheus
192+
kubectl get svc -n prometheus
193+
```
194+
195+
<img width="1440" alt="Screenshot 2023-06-07 at 12 11 12 AM" src="https://github.com/RohanRusta21/InternetSpeed/assets/110477025/310078d6-6325-4d16-9e79-f25b1ca6da90">
196+
197+
198+
199+
200+
201+
Edit Prometheus Service (Edit type : LoadBalancer)
202+
```sh
203+
kubectl edit svc stable-kube-prometheus-sta-prometheus -n prometheus
204+
```
205+
206+
Edit Grafana Service (Edit type : LoadBalancer)
207+
```sh
208+
kubectl edit svc stable-grafana -n prometheus
209+
```
210+
211+
Verify if service is changed to LoadBalancer and also to get the Load Balancer URL.
212+
```sh
213+
kubectl get svc -n prometheus
214+
```
215+
216+
217+
218+
<img width="1440" alt="Screenshot 2023-06-07 at 12 11 40 AM" src="https://github.com/RohanRusta21/InternetSpeed/assets/110477025/17cb107e-2974-493d-bbf4-4f759b4a0682">
219+
220+
221+
222+
223+
<img width="1440" alt="Screenshot 2023-06-07 at 12 13 00 AM" src="https://github.com/RohanRusta21/InternetSpeed/assets/110477025/47be03ab-8568-41e8-bf85-b25bb4e7f17e">
224+
225+
226+
227+
228+
Access Grafana Dashboard
229+
```sh
230+
UserName: admin
231+
Password: prom-operator
232+
```
233+
234+
<img width="1440" alt="Screenshot 2023-06-07 at 12 15 32 AM" src="https://github.com/RohanRusta21/InternetSpeed/assets/110477025/40efcfec-157c-42a1-8f9e-349c038ddbc9">
235+
236+
237+
![Screenshot 2023-06-07 at 12 16 32 AM](https://github.com/RohanRusta21/InternetSpeed/assets/110477025/5be592cf-d01d-481a-ac24-c3f10c518d95)
238+
239+
240+
241+
242+
- Prometheus UI also used LoadBalancer to access in Browser
243+
244+
<img width="1440" alt="Screenshot 2023-06-07 at 12 17 24 AM" src="https://github.com/RohanRusta21/InternetSpeed/assets/110477025/b7967d9b-56d4-4361-8fec-755c549ea026">
245+
246+
247+
248+
249+
#### Creating Customised Monitoring Dashboard using Prometheus & Grafana
250+
251+
- Prometheus is used to gather the dynamic realtime timeseries metrics of nodes from kubelet and we used it to give data to grafana so that we can used it to visualize
252+
- In Grafana I have used Prometheus as a data source and grafana retrieves data from prometheus using queries.
253+
254+
255+
<img width="1440" alt="Screenshot 2023-06-07 at 12 18 18 AM" src="https://github.com/RohanRusta21/InternetSpeed/assets/110477025/5293598b-c1fb-47b2-92e1-957c4aa687be">
256+
257+
258+
259+
# Our Dynamic Customised Monitoring Dashboard for our cluster
260+
261+
262+
- I have used Memory & CPU metrics for the pods and nodes.
263+
- For checking the realtime scaling and replicas of the deployment we can use other queries to retrieve data.
264+
- Frontend & Backend Containers can also be monitored in the dashboard.
265+
266+
267+
268+
<img width="1440" alt="Screenshot 2023-06-07 at 12 43 36 AM" src="https://github.com/RohanRusta21/InternetSpeed/assets/110477025/3b79b96f-704f-4278-b164-d726692ddfac">
269+
270+

0 commit comments

Comments
 (0)