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 #22

Open
wants to merge 2 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
15 changes: 15 additions & 0 deletions .infrastructure/NodePort.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: todoapp-nodeport-service
namespace: todoapp
spec:
type: NodePort
selector:
app: todolist
type: NodePort
ports:
- protocol: TCP
port: 80
targetPort: 8080
nodePort: 30007
6 changes: 2 additions & 4 deletions .infrastructure/busybox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,5 @@ metadata:
spec:
containers:
- name: busybox
image: radial/busyboxplus:curl
args:
- sleep
- "1000"
image: curlimages/curl
command: ["sleep", "1000"]
13 changes: 13 additions & 0 deletions .infrastructure/clusterIP.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: todoapp-clusterip-service
namespace: todoapp
spec:
selector:
app: todolist
type: ClusterIP
ports:
- protocol: TCP
port: 80
targetPort: 8080
2 changes: 1 addition & 1 deletion .infrastructure/namespace.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: todoapp
name: todoapp
36 changes: 34 additions & 2 deletions .infrastructure/todoapp-pod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@ kind: Pod
metadata:
name: todoapp
namespace: todoapp
labels:
app: todolist
spec:
containers:
- name: todoapp
image: ikulyk404/todoapp:3.0.0
image: kagerou4649/todoapp:3.1.0
ports:
- containerPort: 8080
env:
name: EXTERNAL_ENDPOINT
value: http://todoapp-clusterip.todoapp.svc.cluster.local
livenessProbe:
httpGet:
path: api/health
Expand All @@ -17,7 +22,34 @@ spec:
periodSeconds: 5
readinessProbe:
httpGet:
path: api/ready
path: api/readiness
port: 8080
initialDelaySeconds: 5
periodSeconds: 5
---
apiVersion: v1
kind: Pod
metadata:
name: todoapp
namespace: todoapp
spec:
containers:
- name: todoapp
image: kagerou4649/todoapp:3.1.0
ports:
- containerPort: 8080
env:
name: EXTERNAL_ENDPOINT
value: http://todoapp-clusterip.todoapp.svc.cluster.local
livenessProbe:
httpGet:
path: api/health
port: 8080
initialDelaySeconds: 60
periodSeconds: 5
readinessProbe:
httpGet:
path: api/readiness
port: 8080
initialDelaySeconds: 5
periodSeconds: 5
53 changes: 17 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,24 @@
# Django ToDo list
# Apply namespace
kubectl apply -f .\.infrastructure\namespace.yml

This is a todo list web application with basic features of most web apps, i.e., accounts/login, API, and interactive UI. To do this task, you will need:
# Apply pods
kubectl apply -f .\.infrastructure\todoapp-pod.yml

- CSS | [Skeleton](http://getskeleton.com/)
- JS | [jQuery](https://jquery.com/)
# Apply busybox
kubectl apply -f .\.infrastructure\busybox.yml

## Explore
# Apply ClusterIP
kubectl apply -f .\.infrastructure\clusterip.yml

Try it out by installing the requirements (the following commands work only with Python 3.8 and higher, due to Django 4):
# Apply NodePort
kubectl apply -f .\.infrastructure\nodeport.yml

```
pip install -r requirements.txt
```
# Enter busybox container and test connection
kubectl -n todoapp exec -it busybox -- sh
curl http://todoapp-clusterip.todoapp.svc.cluster.local

Create a database schema:
# Test ToDo application using the service port-forward command
kubectl port-forward service/todoapp-clusterip 8081:80

```
python manage.py migrate
```

And then start the server (default is http://localhost:8000):

```
python manage.py runserver
```

Now you can browse the [API](http://localhost:8000/api/) or start on the [landing page](http://localhost:8000/).

## Task

Create a kubernetes manifest for a pod which will containa ToDo app container:

1. Fork this repository.
1. Modify pod manifest to deploy a second same pod with a different name.
1. Add labels to pods “app: todolist”
1. Create a manifest for a ClusterIP service, which should balance traffic between two pods
1. Create a manifest for a NodePort service, which should expose an application on a Node Level
1. Set all env values for the container from pod’s manifest
1. `README.md` should contain instructions on how to test an app by calling a ClusterIP service DNS from a busybox 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.
# Access an application using NodePort Service
http://localhost:30011