Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution #26

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

*/*/__pycache__/*
*/*/*/__pycache__/*
src/db.sqlite3
13 changes: 13 additions & 0 deletions .infrastructure/clusterip-service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: todoapp-clusterip
namespace: todoapp
spec:
selector:
app: todolist
ports:
- protocol: TCP
port: 80
targetPort: 8080
type: ClusterIP
14 changes: 14 additions & 0 deletions .infrastructure/nodeport-service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
name: todoapp-nodeport
namespace: todoapp
spec:
selector:
app: todolist
ports:
- protocol: TCP
port: 80
targetPort: 8080
nodePort: 30007
type: NodePort
37 changes: 36 additions & 1 deletion .infrastructure/todoapp-pod.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,49 @@
apiVersion: v1
kind: Pod
metadata:
name: todoapp
name: todoapp-1
namespace: todoapp
labels:
app: todolist
spec:
containers:
- name: todoapp
image: ikulyk404/todoapp:3.0.0
ports:
- containerPort: 8080
env:
- name: ENVIRONMENT
value: "production"
livenessProbe:
httpGet:
path: api/health
port: 8080
initialDelaySeconds: 60
periodSeconds: 5
readinessProbe:
httpGet:
path: api/ready
port: 8080
initialDelaySeconds: 5
periodSeconds: 5

---
apiVersion: v1
kind: Pod
metadata:
name: todoapp-2
namespace: todoapp
labels:
app: todolist
spec:
containers:
- name: todoapp
image: ikulyk404/todoapp:3.0.0
ports:
- containerPort: 8080
env:
- name: ENVIRONMENT
value: "production"
livenessProbe:
httpGet:
path: api/health
Expand Down
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,35 @@ Create a kubernetes manifest for a pod which will containa ToDo app container:
1. `README.md` file should contain instructions on how to test ToDo application using the service `port-forward` command
1. `README.md` should contain instruction on how to access an app using a NodePort Service
1. Create PR with your changes and attach it for validation on a platform.


## Testing the Application Using ClusterIP Service DNS from a Busybox Container

To verify that the `ClusterIP` service is correctly routing traffic to the `todoapp` pods, you can use a `busybox` container to test DNS resolution and connectivity.

### Steps:

1. **Deploy a Busybox Pod:**
First, deploy a `busybox` pod in the same `todoapp` namespace that will be used to test DNS resolution.

```bash
kubectl run busybox --image=busybox --restart=Never --namespace=todoapp -- sleep 3600
```
This command will create a busybox pod that will run for 1 hour (3600 seconds), allowing to execute commands within it.

2. **Execute DNS Resolution Test:** Once the busybox pod is running, you can use it to test the DNS resolution of the ClusterIP service:
```
kubectl exec -n todoapp busybox -- nslookup todoapp-clusterip
```
You should see an output that resolves the DNS name todoapp-clusterip to the corresponding ClusterIP address.

3. **Test Connectivity to the ToDo Application:**
After confirming DNS resolution, test the connectivity to the ToDo application using the wget command:
```
kubectl exec -n todoapp busybox -- wget -O- todoapp-clusterip
```
This command will attempt to access the ToDo application through the ClusterIP service, and you should see the HTML output of the application's homepage if everything is configured correctly.
4. **Cleanup:** Once you've finished testing, you can delete the busybox pod:
```
kubectl delete pod busybox -n todoapp
```