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

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/confgiMap.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"
14 changes: 11 additions & 3 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 @@ -19,7 +19,7 @@ spec:
spec:
containers:
- name: todoapp
image: ikulyk404/todoapp:3.0.0
image: andr1yk/todoapp:3.1.0
resources:
requests:
memory: "256Mi"
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
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="
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,37 @@ Create a kubernetes manifest for a pod which will containa ToDo app container:
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.

## How to apply changes

```bash
kubectl apply -f .infrasctructure/configMap.yml
kubectl apply -f .infrasctructure/secret.yml
kubectl apply -f .infrasctructure/deployment.yml
```

## How to validate changes

Check if ConfigMap and Secret were created:

```bash
kubectl get configmap todoapp-config -o jsonpath='{.data.PYTHONUNBUFFERED}'
kubectl get secret todoapp-secret -o jsonpath='{.data.SECRET_KEY}'
```

Check environment variables in the deployment:

```bash
kubectl exec -it deployment/todoapp -- env | grep PYTHONUNBUFFERED
kubectl exec -it deployment/todoapp -- env | grep SECRET_KEY
```

Check if application is working:

```bash
kubectl port-forward deployment/todoapp 8080:8080
```

And then open http://localhost:8080/ in your browser.


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", None)

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