diff --git a/.infrastructure/configMap.yml b/.infrastructure/configMap.yml new file mode 100644 index 0000000..7eecbcb --- /dev/null +++ b/.infrastructure/configMap.yml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: todoapp-config + namespace: todoapp +data: + PYTHONUNBUFFERED: "1" diff --git a/.infrastructure/deployment.yml b/.infrastructure/deployment.yml index 47f8efe..c451e48 100644 --- a/.infrastructure/deployment.yml +++ b/.infrastructure/deployment.yml @@ -19,7 +19,7 @@ spec: spec: containers: - name: todoapp - image: ikulyk404/todoapp:3.0.0 + image: valerakb/todoapp:3.2.0 resources: requests: memory: "256Mi" @@ -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-secrets + key: secret_key ports: - containerPort: 8080 livenessProbe: diff --git a/.infrastructure/secret.yml b/.infrastructure/secret.yml new file mode 100644 index 0000000..d2fb64a --- /dev/null +++ b/.infrastructure/secret.yml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: Secret +metadata: + name: todoapp-secrets + namespace: todoapp +type: Opaque +data: + secret_key: QGUyKHl4KXYmdGdoM19zPTB5amEtaSFkcGVieHN6XmRnNDd4KS1rJmtxXzN6Zio5ZSo= diff --git a/.infrastructure/todoapp-pod.yml b/.infrastructure/todoapp-pod.yml index fc0e169..a426833 100644 --- a/.infrastructure/todoapp-pod.yml +++ b/.infrastructure/todoapp-pod.yml @@ -8,7 +8,7 @@ metadata: spec: containers: - name: todoapp - image: ikulyk404/todoapp:3.0.0 + image: valerakb/todoapp:3.2.0 ports: - containerPort: 8080 livenessProbe: @@ -36,7 +36,7 @@ metadata: spec: containers: - name: todoapp - image: ikulyk404/todoapp:3.0.0 + image: valerakb/todoapp:3.2.0 env: - name: PYTHONUNBUFFERED value: "1" diff --git a/README.md b/README.md index f4c4dfe..c1bf0fa 100644 --- a/README.md +++ b/README.md @@ -44,3 +44,18 @@ 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. + +## To apply our changes use next command: + + kubectl apply -f .infrastructure/configMap.yml + kubectl apply -f .infrastructure/secret.yml + kubectl apply -f .infrastructure/deployment.yml + +## To validate the changes use next command + + kubectl exec -it -- sh + printenv + +and find + + SECRET_KEY = \ No newline at end of file diff --git a/src/todolist/settings.py b/src/todolist/settings.py index e00a954..adc458a 100644 --- a/src/todolist/settings.py +++ b/src/todolist/settings.py @@ -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.getenv('SECRET_KEY') # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True