You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+64-47Lines changed: 64 additions & 47 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,97 +26,112 @@ The main goal of this exercise was to set up a simple web server inside a Docker
26
26
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`.
27
27
28
28
```Dockerfile
29
-
#Use the official Nginx image
29
+
#Nginx image in the Docker Hub
30
30
FROM nginx:latest
31
-
32
-
# Copy custom index.html to the container's web directory
After writing the Dockerfile, I built the Docker image using the following command:
41
43
```bash
42
-
docker build -t my-nginx-app .
44
+
docker build -t terra-simple-nginx-server .
43
45
```
44
46
And ran the container:
45
47
```bash
46
-
docker run -d -p 8002:80 my-nginx-app
48
+
docker run -d -p 8002:80 terra-simple-nginx-server
47
49
```
48
-
49
-
Once this was set up, the web server was live and accessible at `http://localhost:8002`.
50
+
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
51
52
---
53
+
### Health Check
52
54
53
-
### Health Check Configuration
54
-
55
-
A health check is essential to ensure that the container is up and running correctly. To add this, I configured a health check in the Dockerfile, which pings the root path of the web server every 30 seconds to ensure it is alive.
55
+
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.
If the web server does not respond successfully within the set parameters, Docker will consider the container "unhealthy."
61
+
[As shown in the screenshort](https://github.com/Timoo20/info-sec-devops-devsecops-terra/blob/main/images-screenshots/Health-Container-Status.png)
62
+
Incase the web server does not respond successfully within the configured param, then Docker will consider the container "UNHEALTHY."
63
63
64
64
---
65
65
66
66
### Troubleshooting Docker Health Checks
67
67
68
-
During my setup, I encountered an issue where the health check was consistently failing. Here’s how I tackled the issue:
68
+
If I encounter issues with Docker health checks, I would take to troubleshoot the problem by:
69
69
70
-
1.**Check the Logs**: First, I looked at the container logs using `docker logs <container_id>` to see if there were any clues about errors or misconfigurations.
71
-
72
-
2.**Examine the Health Check Status**: Using the command `docker inspect --format='{{json .State.Health}}' <container_id>`, I was able to inspect the health check status and pinpoint the issue.
70
+
1.**Checking the Logs**:
71
+
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:
72
+
```bash
73
+
docker logs 350df94ecfdc
74
+
---
75
+
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.
73
76
74
-
3.**Test the Web Server Directly**: To rule out potential networking issues, I accessed the container directly using `docker exec` and tested the server internally with `curl`.
77
+
2. **Examine the Health Check Status:**
75
78
76
-
4.**Increase Timeout & Retry Settings**: Finally, I tweaked the health check settings, such as increasing the timeout and retry count, which helped the container pass the health check successfully.
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.
77
84
78
-
---
79
85
80
-
## Scenario-Based Troubleshooting
86
+
3. **Teting in web server directly:**
87
+
88
+
I access the container directly and test the web server inside using curl. This helps in fixing network issues.
89
+
90
+
91
+
4. **Increasing the Timeout & Retry Configuration::**
92
+
93
+
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.
94
+
95
+
96
+
97
+
## PART 2
81
98
82
99
### Scenario 1: Failing Health Checks in Docker
83
100
84
-
Sometimes, health checks can fail due to various reasons, like misconfigurations or network issues. In my case, the Docker health check was failing.
101
+
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:
85
102
86
-
#### Here's how I solved it:
87
-
1.**Inspect the Health Check Output**: I started by using `docker inspect` to get more details about the health check status, which pointed out that the issue was a time-out from the health check ping.
103
+
1. **Inspecting the Health Checks**: I would utilize `docker inspect` to get finer details about the health status.
88
104
89
-
2.**Check the Web Server Logs**: The logs revealed that Nginx was not fully loading the content due to a missing file.
105
+
2. **Checking the Web Server Logs**: I would keenly check the server logs.
90
106
91
-
3.**Adjust the Health Check Parameters**: After resolving the file issue, I adjusted the health check’s timeout and retries to give the container a little more time to respond.
92
-
93
-
4.**Rebuild the Container**: Once the changes were made, I rebuilt the Docker container and ran it again. This time, the health check passed, confirming the issue was resolved.
107
+
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 inthe timeout onfiguration, I would consider extending it to about 10 Seconds.
108
+
109
+
4. **Rebuilding the Container**: I will rebuilt the container and ran it again.
94
110
95
111
---
96
112
97
113
### Scenario 2: Nginx Ingress Not Accessible
98
114
99
-
In this scenario, I exposed a service via **Nginx Ingress**, but it wasn’t accessible over the internet. Here’s how I approached the troubleshooting:
115
+
In this scenario, this is how I would approach the troubleshooting:
100
116
101
-
1.**Check the Ingress Controller**: I first made sure that the **Nginx Ingress Controller** was properly set up and running in my Kubernetes cluster by using `kubectl get pods -n ingress-nginx`.
117
+
1. **Checking the Ingress Controller**: I would first assess the Ingress Controller to ensure that it is up and running.
102
118
103
-
2.**Inspect the Ingress Resource**: I verified that the **Ingress Resource** was configured correctly with the correct **host** and **service** details.
119
+
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.
104
120
105
-
3.**DNS and Routing**: Next, I checked if the DNS settings were correctly pointing to the IP address of the Ingress controller.
121
+
3. **DNS checking**: I would check the DNS settings to ensure that they are correctly pointing to the exact Ingress controller - IP address.
106
122
107
-
4.**Firewall Rules**: I made sure that the relevant ports (80/443) were open in the cloud provider’s security group or firewall.
123
+
4. **Firewall Rules**: I would check if the ports Port 80/443 were open in the cloud provider’s security group or firewall.
108
124
109
-
5.**Nginx Logs**: Finally, I looked at the logs of the **Nginx Ingress Controller** to check for any issues in routing or configuration.
125
+
5. **Nginx Logs**: Finally, I would look at the logs to check forany issuesin routing or configuration.
110
126
111
127
---
112
128
113
129
## Tech Stack Used
114
130
115
-
-**Docker**: To build and run the containerized web application.
116
-
-**Nginx**: Used as the web server to serve the content.
117
-
-**Kubernetes & Ingress**: To manage and expose services in a Kubernetes environment.
118
-
-**Curl & Wget**: For testing service health and availability.
119
-
-**YAML & Dockerfiles**: For configuration management and defining services.
131
+
- **Docker**: To build and run the terra-simple-nginx-server application.
132
+
- **Nginx**: Utilized as the web server to serve the content.
133
+
- **Curl**: For testing service health and availability.
134
+
- **Yaml & Dockerfiles**: For configuration management.
120
135
121
136
---
122
137
@@ -125,19 +140,21 @@ In this scenario, I exposed a service via **Nginx Ingress**, but it wasn’t acc
125
140
To get started with this project, you'll need:
126
141
127
142
- **Docker** installed on your local machine or VM.
128
-
-**Kubernetes** (optional, for the Nginx Ingress exercise).
129
143
- Access to a terminal to run the commands and build the containers.
130
144
131
145
---
132
146
## About Me & Contact
133
147
134
-
I'm a **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
+
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.
135
149
136
150
If you want to connect or have any questions about this repository or the exercises, feel free to reach out!
**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)
0 commit comments