MonitoringWebTraffic / secrets.txt
secrets.txt
Raw
First, I need to create a secret in Kubernetes. The command I used is: kubectl create secret generic k-secret --from-literal='mysql-root-password=thisisatestthing.' --from-literal='django-secret-key=kmgysa#fz+9(z1*=c0ydrjizk*7sthm2ga1z4=^61$cxcq8b$l'

This command will create a secret called k-secret that has 2 key value: mysql-root-password and django-secret-key. Then I go to django-deploy.yaml and change the code as follow:
 - name: MYSQL_ROOT_PASSWORD
              valueFrom:
                secretKeyRef: 
                  name: k-secret
                  key: mysql-root-password  
 - name: DJANGO_SECRET_KEY
              valueFrom:
                  secretKeyRef:
                    name: k-secret
                    key: django-secret-key

Also I go to db/k8/db-deployment.yaml and change the code as well:
- name: MYSQL_ROOT_PASSWORD
              valueFrom:
                secretKeyRef: 
                  name: k-secret
                  key: mysql-root-password

Lastly, I need to change the SECRET_KEY in settings.py:
	SECRET_KEY =  os.environ['DJANGO_SECRET_KEY']
I passing the environment variable named DJANGO_SECRET_KEY in the django-deploy.yaml to the SECRET_KEY in settings.py