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

Open
wants to merge 1 commit 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
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
namespace: todoapp
spec:
selector:
app: todolist
ports:
- protocol: TCP
port: 80
targetPort: 8080
type: ClusterIP
14 changes: 14 additions & 0 deletions .infrastructure/nodeport.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:
type: NodePort
selector:
app: todolist
ports:
- protocol: TCP
port: 80
targetPort: 8080
nodePort: 30007
31 changes: 30 additions & 1 deletion .infrastructure/todoapp-pod.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,37 @@
apiVersion: v1
kind: Pod
metadata:
name: todoapp
name: todoapp-0
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

---
apiVersion: v1
kind: Pod
metadata:
name: todoapp-1
namespace: todoapp
labels:
app: todolist
spec:
containers:
- name: todoapp
Expand Down
61 changes: 32 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,46 @@
# Django ToDo list
# Kubernetes TodoApp Deployment

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:

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

## Explore

Try it out by installing the requirements (the following commands work only with Python 3.8 and higher, due to Django 4):
## 1. Apply the manifests to create the namespace, TodoApp pods, and BusyBox pod:

Run the following command to apply all manifests within the ./.infrastructure directory:
```bash
kubectl apply -f ./.infrastructure
```
pip install -r requirements.txt

Or apply each manifest individually as follows:
```bash
kubectl apply -f ./.infrastructure/namespace.yml
kubectl apply -f ./.infrastructure/clusterip.yml
kubectl apply -f ./.infrastructure/nodeport.yml
kubectl apply -f ./.infrastructure/busybox.yml
kubectl apply -f ./.infrastructure/todoapp-pod.yml
```

Create a database schema:
## 2. Test the TodoApp using the ClusterIP service:

To test the TodoApp via the ClusterIP service, follow these steps:

1. Access the BusyBox shell:
```bash
kubectl -n todoapp exec -it busybox -- sh
```
python manage.py migrate

2. Send a curl request to the ClusterIP service DNS:
```bash
curl http://todoapp-clusterip.todoapp.svc.cluster.local
```
This should return a response from the TodoApp if it’s running correctly.

And then start the server (default is http://localhost:8000):
## 3. Test the TodoApp using port-forwarding:

1. Test the TodoApp locally, use port-forwarding to access the service:
```bash
kubectl port-forward service/todoapp-clusterip 8080:80 -n todoapp
```
python manage.py runserver
```

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

## Task
2. Open your web browser and test the TodoApp at:
http://localhost:8080

Create a kubernetes manifest for a pod which will containa ToDo app container:
## 3. Test the TodoApp using the NodePort service in your web browser at:

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.
http://localhost:30007