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

done #35

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

done #35

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
13 changes: 13 additions & 0 deletions .infrastructure/cluster-ip.service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: todoapp-cluster-ip-service
namespace: todoapp
spec:
selector:
app: todolist
ports:
- protocol: TCP
port: 80
targetPort: 8080
type: ClusterIP
14 changes: 14 additions & 0 deletions .infrastructure/node-port.service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
name: todoapp-node-port-service
namespace: todoapp
spec:
type: NodePort
selector:
app: todolist
ports:
- protocol: TCP
port: 80
targetPort: 8080
nodePort: 30007
67 changes: 51 additions & 16 deletions .infrastructure/todoapp-pod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,56 @@ kind: Pod
metadata:
name: todoapp
namespace: todoapp
labels:
app: todolist
spec:
containers:
- name: todoapp
image: ikulyk404/todoapp:3.0.0
ports:
- containerPort: 8080
livenessProbe:
httpGet:
path: api/health
port: 8080
initialDelaySeconds: 60
periodSeconds: 5
readinessProbe:
httpGet:
path: api/ready
port: 8080
initialDelaySeconds: 5
periodSeconds: 5
- name: todoapp
image: ikulyk404/todoapp:3.0.0
env:
- name: PYTHONUNBUFFERED
value: "1"
ports:
- containerPort: 8080
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: todoapp2.0
namespace: todoapp
labels:
app: todolist
spec:
containers:
- name: todoapp
image: ikulyk404/todoapp:3.0.0
env:
- name: PYTHONUNBUFFERED
value: "1"
ports:
- containerPort: 8080
livenessProbe:
httpGet:
path: api/health
port: 8080
initialDelaySeconds: 60
periodSeconds: 5
readinessProbe:
httpGet:
path: api/ready
port: 8080
initialDelaySeconds: 5
periodSeconds: 5
44 changes: 20 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,39 @@
# Django ToDo list

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:
1. Create all pods and services

- CSS | [Skeleton](http://getskeleton.com/)
- JS | [jQuery](https://jquery.com/)
```
bash

## Explore
kubectl apply -f ./.infrastructure
```

Try it out by installing the requirements (the following commands work only with Python 3.8 and higher, due to Django 4):
2. Test app by ClusterIP and busybox

```
pip install -r requirements.txt
bash

kubectl -n todoapp exec -it busybox -- sh
```

Create a database schema:
and run

```
python manage.py migrate
bash

curl http://todoapp-cluster-ip-service.todoapp.svc.cluster.local
```

And then start the server (default is http://localhost:8000):
3. Test app by ClusterIP and port-forward

```
python manage.py runserver
```
bash

Now you can browse the [API](http://localhost:8000/api/) or start on the [landing page](http://localhost:8000/).
kubectl port-forward svc/todoapp-cluster-ip-service 8080:80 -n todoapp
```

## Task
Open http://localhost:8080

Create a kubernetes manifest for a pod which will containa ToDo app container:
4. Test app by NodePort

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.
Open http://localhost:30007
4 changes: 1 addition & 3 deletions src/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ FROM python:${PYTHON_VERSION} as run

WORKDIR /app

ENV PYTHONUNBUFFERED=1

COPY --from=builder /app .

RUN pip install --upgrade pip && \
Expand All @@ -21,4 +19,4 @@ RUN pip install --upgrade pip && \
RUN python manage.py migrate

# Run database migrations and start the Django application
ENTRYPOINT ["python", "manage.py", "runserver", "0.0.0.0:8080"]
ENTRYPOINT ["python", "manage.py", "runserver", "0.0.0.0:8080"]