Skip to content

Commit f1956c2

Browse files
committed
Customized the questions to meet the assessment
1 parent 524d636 commit f1956c2

File tree

8 files changed

+222
-31
lines changed

8 files changed

+222
-31
lines changed

.github/workflows/docker-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
#Command for buiding the image
1+
#buiding the image
22

33
docker build -t terra-simple-nginx-server .

docs/PROCESS.md

Whitespace-only changes.

docs/PROCESSES_STEPS.md

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
# Terra info-sec-devsecops
2+
---
3+
## Table of Contents
4+
1. [PART 1](#PART-1)
5+
- [Step-by-Step Setup](#step-by-step-setup)
6+
- [Health Check Configuration](#health-check)
7+
- [Troubleshooting Docker Health Checks](#troubleshooting-docker-health-checks)
8+
2. [PART 2](#PART-2)
9+
- [Scenario 1: Failing Health Checks in Docker](#scenario-1-failing-health-checks-in-docker)
10+
- [Scenario 2: Nginx Ingress Not Accessible](#scenario-2-nginx-ingress-not-accessible)
11+
3. [Tech Stack](#tech-stack)
12+
4. [Requirements](#requirements)
13+
5. [About Me & Contact](#about-me--contact)
14+
15+
---
16+
17+
## PART 1
18+
19+
### Step-by-Step Setup
20+
21+
The main goal of this exercise was to set up a simple web server inside a Docker container, running on port `8002`. I chose **Nginx** as the web server for this project due to its lightweight and efficient nature.
22+
23+
#### The steps I followed were:
24+
1. **Creating the Dockerfile**: I started by creating a `Dockerfile` to configure the web server. The Dockerfile uses the official **Nginx** image, and it exposes the application on port `8002`.
25+
As demonstrated in [Configuration](https://github.com/Timoo20/info-sec-devops-devsecops-terra/blob/main/Dockerfile)
26+
```Dockerfile
27+
# Nginx image in the Docker Hub
28+
FROM nginx:latest
29+
# Nginx configuration
30+
COPY nginx/nginx.conf /etc/nginx/nginx.conf
31+
# Exposing the port 8002
32+
EXPOSE 8002
33+
# Health Check
34+
HEALTHCHECK --interval=30s --timeout=5s --retries=3 \
35+
CMD curl -f http://localhost:8002/ || exit 1
36+
# default command to run Nginx
37+
CMD ["nginx", "-g", "daemon off;"]
38+
```
39+
2. **Building and Running the Container**:
40+
After writing the Dockerfile, I built the Docker image using the following command:
41+
As demonstrated in [Runninng](https://github.com/Timoo20/info-sec-devops-devsecops-terra/blob/main/.github/workflows/docker-build.yml)
42+
```bash
43+
docker build -t terra-simple-nginx-server .
44+
```
45+
And ran the container:
46+
```bash
47+
docker run -d -p 8002:80 terra-simple-nginx-server
48+
```
49+
The web server was live and accessible at `http://localhost:8002`. [As shown in the Screenshort](https://github.com/Timoo20/info-sec-devops-devsecops-terra/blob/main/images-screenshots/Validating%20in%20localhost.png)
50+
51+
---
52+
### Health Check
53+
54+
A health check is important as it ensures that the container is up and running perfectly; as expected. To achieve this, I configured a health check in the Dockerfile that pings the root path of the web server every 30 seconds to ensure it is alive.
55+
56+
```Dockerfile
57+
HEALTHCHECK --interval=30s --timeout=10s --retries=3 \
58+
CMD curl --silent --fail http://localhost:8002/ || exit 1
59+
```
60+
[As shown in the screenshort](https://github.com/Timoo20/info-sec-devops-devsecops-terra/blob/main/images-screenshots/Health-Container-Status.png)
61+
Incase the web server does not respond successfully within the configured param, then Docker will consider the container "UNHEALTHY."
62+
63+
---
64+
65+
### Troubleshooting Docker Health Checks
66+
67+
If I encounter issues with Docker health checks, I would take to troubleshoot the problem by:
68+
69+
1. **Checking the Logs**:
70+
First, I would check the container logs to gather any clues about errors or misconfigurations that might be affecting the health check. For example, I ran the following command for my container:
71+
```bash
72+
docker logs 350df94ecfdc
73+
---
74+
The logs showed the server returning the expected **"Hey! This is hello from Terra Software Company. Welcome to your Nginx server" **message, which confirmed the web server was functioning correctly.
75+
76+
2. **Examine the Health Check Status:**
77+
78+
```bash
79+
docker inspect --format='{{json .State.Health}}' 350df94ecfdc
80+
---
81+
82+
When I executed the command, it showed that it is in healthy [As shown in the screenshort](https://github.com/Timoo20/info-sec-devops-devsecops-terra/blob/main/images-screenshots/Health-Container-Status.png) ; hence confirming the container was in good health.
83+
84+
85+
3. **Teting in web server directly:**
86+
87+
I access the container directly and test the web server inside using curl. This helps in fixing network issues.
88+
89+
90+
4. **Increasing the Timeout & Retry Configuration::**
91+
92+
I would change the health params to fix the issue. For example; instead of 5 seconds in the timeout onfiguration, I would consider extending it to about 10 Seconds.
93+
94+
95+
96+
## PART 2
97+
98+
### Scenario 1: Failing Health Checks in Docker
99+
100+
Health checks can fail because of misconfigurations or maybe because of network issues. In my case, the Docker health check was successful. Incase Docker fails, i would have considered:
101+
102+
1. **Inspecting the Health Checks**: I would utilize `docker inspect` to get finer details about the health status.
103+
104+
2. **Checking the Web Server Logs**: I would keenly check the server logs.
105+
106+
3. **Fine tuning the the Health Check Params**: I would fine tune the health params to fix the issue. For example; instead of 5 seconds in the timeout onfiguration, I would consider extending it to about 10 Seconds.
107+
108+
4. **Rebuilding the Container**: I will rebuilt the container and ran it again.
109+
110+
---
111+
112+
### Scenario 2: Nginx Ingress Not Accessible
113+
114+
In this scenario, this is how I would approach the troubleshooting:
115+
116+
1. **Checking the Ingress Controller**: I would first assess the Ingress Controller to ensure that it is up and running.
117+
118+
2. **Inspecting the Ingress Resource**: I would keenly verify the ingress Resource; to ensure that it is properly correctly with the correct **service** and **host** details.
119+
120+
3. **DNS checking**: I would check the DNS settings to ensure that they are correctly pointing to the exact Ingress controller - IP address.
121+
122+
4. **Firewall Rules**: I would check if the ports Port 80/443 were open in the cloud provider’s security group or firewall.
123+
124+
5. **Nginx Logs**: Finally, I would look at the logs to check for any issues in routing or configuration.
125+
126+
---
127+
128+
## Tech Stack
129+
130+
- **Docker**: To build and run the terra-simple-nginx-server application.
131+
- **Nginx**: Utilized as the web server to serve the content.
132+
- **Curl**: For testing service health and availability.
133+
- **Yaml & Dockerfiles**: For configuration management.
134+
135+
---
136+
137+
## Requirements
138+
139+
To get started with this project, you'll need:
140+
141+
- **Docker** installed on your local machine or VM.
142+
- Access to a terminal to run the commands and build the containers.
143+
144+
---
145+
## About Me & Contact
146+
147+
I'm a **Developer/Cybersecurity/DevSecOps/DevOps professional** passionate about building secure, scalable, and efficient applications. I focus on bridging the gap between development and security to create seamless solutions that are both effective and safe.
148+
149+
If you want to connect or have any questions about this repository or the exercises, feel free to reach out!
150+
151+
- **Email**: [[email protected]](mailto:[email protected])
152+
- **LinkedIn**: [Tim Murkomen](https://www.linkedin.com/in/timoo20/)
153+
---
154+
## LICENCE
155+
**License**: This project is Licensed under a Tim Murkomen Custom License by Tim Murkomen - Here is the Link [Custom Licence](https://github.com/Timoo20/info-sec-devops-devsecops-terra/blob/main/LICENSE)
156+
157+
---
158+
Contributor: [Tim Murkomen](https://github.com/Timoo20)
159+
---

docs/STEPS.md

Whitespace-only changes.

docs/TROUBLESHOOTING.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
### Troubleshooting Docker Health Checks
2+
3+
If I encounter issues with Docker health checks, I would take to troubleshoot the problem by:
4+
5+
1. **Checking the Logs**:
6+
First, I would check the container logs to gather any clues about errors or misconfigurations that might be affecting the health check. For example, I ran the following command for my container:
7+
```bash
8+
docker logs 350df94ecfdc
9+
---
10+
The logs showed the server returning the expected **"Hey! This is hello from Terra Software Company. Welcome to your Nginx server" **message, which confirmed the web server was functioning correctly.
11+
12+
2. **Examine the Health Check Status:**
13+
14+
```bash
15+
docker inspect --format='{{json .State.Health}}' 350df94ecfdc
16+
---
17+
18+
When I executed the command, it showed that it is in healthy [As shown in the screenshort](https://github.com/Timoo20/info-sec-devops-devsecops-terra/blob/main/images-screenshots/Health-Container-Status.png) ; hence confirming the container was in good health.
19+
20+
21+
3. **Teting in web server directly:**
22+
23+
I access the container directly and test the web server inside using curl. This helps in fixing network issues.
24+
25+
26+
4. **Increasing the Timeout & Retry Configuration::**
27+
28+
I would change the health params to fix the issue. For example; instead of 5 seconds in the timeout onfiguration, I would consider extending it to about 10 Seconds.
29+
30+
31+
32+
## PART 2
33+
34+
### Scenario 1: Failing Health Checks in Docker
35+
36+
Health checks can fail because of misconfigurations or maybe because of network issues. In my case, the Docker health check was successful. Incase Docker fails, i would have considered:
37+
38+
1. **Inspecting the Health Checks**: I would utilize `docker inspect` to get finer details about the health status.
39+
40+
2. **Checking the Web Server Logs**: I would keenly check the server logs.
41+
42+
3. **Fine tuning the the Health Check Params**: I would fine tune the health params to fix the issue. For example; instead of 5 seconds in the timeout onfiguration, I would consider extending it to about 10 Seconds.
43+
44+
4. **Rebuilding the Container**: I will rebuilt the container and ran it again.
45+
46+
---
47+
48+
### Scenario 2: Nginx Ingress Not Accessible
49+
50+
In this scenario, this is how I would approach the troubleshooting:
51+
52+
1. **Checking the Ingress Controller**: I would first assess the Ingress Controller to ensure that it is up and running.
53+
54+
2. **Inspecting the Ingress Resource**: I would keenly verify the ingress Resource; to ensure that it is properly correctly with the correct **service** and **host** details.
55+
56+
3. **DNS checking**: I would check the DNS settings to ensure that they are correctly pointing to the exact Ingress controller - IP address.
57+
58+
4. **Firewall Rules**: I would check if the ports Port 80/443 were open in the cloud provider’s security group or firewall.
59+
60+
5. **Nginx Logs**: Finally, I would look at the logs to check for any issues in routing or configuration.
61+
62+
---

scripts/health_check.sh

Lines changed: 0 additions & 8 deletions
This file was deleted.

scripts/test_nginx.sh

Lines changed: 0 additions & 11 deletions
This file was deleted.

tests/test_health_check.sh

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)