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_v1.0 #18

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
2 changes: 1 addition & 1 deletion .infrastructure/clusterIp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v1
kind: Service
metadata:
name: todoapp-service
namespace: todoapp
namespace: mateapp
spec:
type: ClusterIP
selector:
Expand Down
7 changes: 7 additions & 0 deletions .infrastructure/configMap.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: todoapp-config
namespace: mateapp
data:
PYTHONUNBUFFERED: "1"
12 changes: 10 additions & 2 deletions .infrastructure/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: todoapp
namespace: todoapp
namespace: mateapp
spec:
strategy:
type: RollingUpdate
Expand All @@ -29,7 +29,15 @@ spec:
cpu: "150m"
env:
- name: PYTHONUNBUFFERED
value: "1"
valueFrom:
configMapKeyRef:
name: todoapp-config
key: PYTHONUNBUFFERED
- name: SECRET_KEY
valueFrom:
secretKeyRef:
name: todoapp-secret
key: SECRET_KEY
ports:
- containerPort: 8080
livenessProbe:
Expand Down
2 changes: 1 addition & 1 deletion .infrastructure/hpa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: todoapp
namespace: todoapp
namespace: mateapp
spec:
scaleTargetRef:
apiVersion: apps/v1
Expand Down
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: mateapp
2 changes: 1 addition & 1 deletion .infrastructure/nodeport.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v1
kind: Service
metadata:
name: todoapp-nodeport
namespace: todoapp
namespace: mateapp
spec:
type: NodePort
selector:
Expand Down
8 changes: 8 additions & 0 deletions .infrastructure/secret.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: Secret
metadata:
name: todoapp-secret
namespace: mateapp
type: Opaque
data:
SECRET_KEY: "QGUyKHl4KXYmdGdoM19zPTB5amEtaSFkcGVieHN6XmRnNDd4KS1rJmtxXzN6Zio5ZSo="
51 changes: 19 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,46 +1,33 @@
# 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:

- 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. Recreate and check features from previous tasks

```
pip install -r requirements.txt
kubectl apply -f .infrastructure/namespace.yml
kubectl config set-context --current --namespace=mateapp
kubectl apply -f .infrastructure/clusterIp.yml
kubectl apply -f .infrastructure/nodeport.yml
kubectl get svc -o wide
```

Create a database schema:
2. Create and check configMap setup

```
python manage.py migrate
kubectl apply -f .infrastructure/configMap.yml
kubectl get configmap -o wide
```

And then start the server (default is http://localhost:8000):
3. Create and check secret setup

```
python manage.py runserver
kubectl apply -f .infrastructure/secret.yml
kubectl get configmap -o wide
```

Now you can browse the [API](http://localhost:8000/api/) or start on the [landing page](http://localhost:8000/).
4. Create and check successfully created deployment

## Task

Create a kubernetes manifest for a pod which will containa ToDo app container:
```
kubectl apply -f .infrastructure/deployment.yml
kubectl get deployments -o wide
kubectl get pods -o wide
```

1. Fork this repository.
1. Create a `confgiMap.yml` file for ConfigMap resource.
1. ConfigMap requirements:
3.1. ConfigMap should have a `PYTHONUNBUFFERED` values set
3.2. Deployment shoyld use this ConfigMap and set `PYTHONUNBUFFERED` environment variable
1. Create a `secret.yml` file for Secret resource.
1. Secret requirements:
5.1. Secret should have a `SECRET_KEY` value set
5.2. Deployment should use this Secret and set `SECRET_KEY` environment variable
5.3. Application should use this secret instead of one hardcoded in `settings.py`
1. `README.md` should have commands to apply all the changes
1. `README.md` should have instructuions on how to validate the changes
1. Create PR with your changes and attach it for validation on a platform.
5. Now you can enjoy fantastic todo application on http://localhost:30007/ or http://127.0.0.1:30007
2 changes: 1 addition & 1 deletion src/todolist/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = "@e2(yx)v&tgh3_s=0yja-i!dpebxsz^dg47x)-k&kq_3zf*9e*"
SECRET_KEY = os.environ.get("SECRET_KEY", "")

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
Expand Down