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

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
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: todoapp
data:
PYTHONUNBUFFERED: "1"
66 changes: 37 additions & 29 deletions .infrastructure/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ kind: Deployment
metadata:
name: todoapp
namespace: todoapp
labels:
app: todoapp
spec:
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
replicas: 2
selector:
matchLabels:
app: todoapp
Expand All @@ -18,29 +18,37 @@ spec:
app: todoapp
spec:
containers:
- name: todoapp
image: ikulyk404/todoapp:3.0.0
resources:
requests:
memory: "256Mi"
cpu: "150m"
limits:
memory: "256Mi"
cpu: "150m"
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
- name: todoapp
resources:
requests:
memory: "128Mi"
cpu: "500m"
limits:
memory: "512Mi"
cpu: "800m"
image: fredfredburger/todoapp:3.0.3
ports:
- containerPort: 8000
livenessProbe:
httpGet:
path: api/health
port: 8000
initialDelaySeconds: 60
periodSeconds: 5
readinessProbe:
httpGet:
path: api/readiness
port: 8000
initialDelaySeconds: 5
periodSeconds: 5
env:
- name: PYTHONUNBUFFERED
valueFrom:
configMapKeyRef:
name: todoapp-config
key: PYTHONUNBUFFERED
- name: SECRET_KEY
valueFrom:
secretKeyRef:
name: todoapp-secret
key: SECRET_KEY
8 changes: 8 additions & 0 deletions .infrastructure/seceret.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: Secret
metadata:
name: todoapp-secret
namespace: todoapp
type: Opaque
data:
SECRET_KEY: "QGUyKHl4KXYmdGdoM19zPTB5amEtaSFkcGVieHN6XmRnNDd4KS1rJmtxXzN6Zio5ZSo="
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
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/)
- JS | [jQuery](https://jquery.com/)

## Explore

Expand Down Expand Up @@ -34,13 +34,17 @@ Create a kubernetes manifest for a pod which will containa ToDo app container:
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
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`
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.

run these commands to create infrastructure: -`kubectl apply -f namespace.yml` -`kubectl apply -f clusterip.yml` -`kubectl apply -f deployment.yml` -`kubectl apply -f daemonset.yml` -`kubectl apply -f cronjob.yml`

to validate changes `kubectl -n todoapp exec -it <your pod app name> -- sh` and from there run `printenv` or `get secret todoapp-secret -o jsonpath=’{.data.*}’ -n todoapp` or `kubectl describe secret todoapp-secret -n todoapp` to get the name of the secret or to get name and value for configmap.
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