diff --git a/.gitignore b/.gitignore index 68bc17f..9aecc6f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,9 @@ __pycache__/ *.py[cod] *$py.class +.idea +DS_Store + # C extensions *.so diff --git a/.infrastructure/configMap.yml b/.infrastructure/configMap.yml new file mode 100644 index 0000000..dc37572 --- /dev/null +++ b/.infrastructure/configMap.yml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: todoapp-config + namespace: mateapp +data: + PYTHONUNBUFFERED: "1" diff --git a/.infrastructure/deployment.yml b/.infrastructure/deployment.yml index 47f8efe..add51ae 100644 --- a/.infrastructure/deployment.yml +++ b/.infrastructure/deployment.yml @@ -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: diff --git a/.infrastructure/secret.yml b/.infrastructure/secret.yml new file mode 100644 index 0000000..f8be5b8 --- /dev/null +++ b/.infrastructure/secret.yml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: Secret +metadata: + name: todoapp-secret + namespace: mateapp +type: Opaque +data: + SECRET_KEY: "QGUyKHl4KXYmdGdoM19zPTB5amEtaSFkcGVieHN6XmRnNDd4KS1rJmtxXzN6Zio5ZSo=" diff --git a/INSTRUCTION.md b/INSTRUCTION.md new file mode 100644 index 0000000..2703f3a --- /dev/null +++ b/INSTRUCTION.md @@ -0,0 +1,10 @@ +In order to set up the secrets and the config map: + +kubectl apply -f .infrastructure/configMap.yml +kubectl apply -f .infrastructure/secret.yml + +In order to validate that the environment variables are set correctly: + +kubectl get pods +kubectl exec -it -- /bin/sh +prinenv \ No newline at end of file diff --git a/src/todolist/settings.py b/src/todolist/settings.py index e00a954..f8b6694 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 @@ -69,10 +69,10 @@ # "default": { # "ENGINE": "django.db.backends.mysql", - # "HOST": "FVFFM3F5Q05N", + # "HOST": "FVFFM3F5Q05N", # "PORT": 3306, # "NAME":"tododb", - # "PASSWORD": "my-secret-pw", + # "PASSWORD": "my-secret-pw", # "USER": "root", # } }