This project is a playground for developing django web application and deploying it on cloud using Heroku, AWS, GCP, Docker, Kubernetes, etc.
Earlier, this project was submitted as an assignment for the BlueStacks position Senior Member of Technical Staff (SMTS). Now, this project is used for experimenting with new technologies.
- Web Framework: Python-Django
- Backend: PostgreSQL
- Frontend: Bootstrap, AngularJs, JQuery
- DevOps: AWS/Heroku/Docker/Kubernetes
- peopleportal/management/commands/initialize_system.py
- peopleportal/middlewares.py
- peopleportal/decorators.py
- Backend
- Frontend
-
Create virtual environment
-
Activate virtual environment
-
Clone project
-
Install project dependencies (requirements.txt)
pip install -r requirements.txt
-
Create
settings.py
inpeopleportal
directory using the templatesettings__template__.py
. Edit all database and other settings variable. -
Apply database migrations:
python manage.py migrate
-
Create superuser
python manage.py createsuperuser
-
Initialize System (Important)
python manage.py initialize_system
-
Run server:
python manage.py runserver
-
Open any browser and go to http://127.0.0.1:8000/ or open http://127.0.0.1:8000/admin/ to configure system.
- Django application:
docker build -t gagan144/peopleportal-djangoapp . docker push gagan144/peopleportal-djangoapp
- File server for kubernetes deployment:
This container image is used to deploy static file behind ingress-nginx in a kubernetes cluster. This is not used in docker-compose setup.docker build -t gagan144/peopleportal-fileserver ./dockers/fileserver-k8s docker push gagan144/peopleportal-fileserver
Docker Hub Link: https://hub.docker.com/r/gagan144/peopleportal-djangoapp
-
Refer
docker-compose.yml
,Dockerfile
, directorydockers/
,peopleportal/_settings_docker.py
file for better understanding. -
Build images and run containers:
Inside the project directory, run the following commanddocker-compose up --build
-
Default django admin credentials:
URL: http://localhost:9000/admin
Username: admin
Password: admin
All kubernetes yaml files are place inside k8s directory. The architecture is as follows:
-
Setup:
-
(IF USING MINIKUBE) Enable minikube ingress add-on:
minikube addons enable ingress
-
(OPTIONAL) Create namespace
ns-peopleportal
:kubectl create namespace ns-peopleportal # Switch to namespace kubectl config set-context --current --namespace=ns-peopleportal
-
Create a k8s Secret:
kubectl create secret generic secret-peopleportal --from-literal PG_PASSWORD=pgrootpass
-
-
Deploy: To deploy the project inside kubernetes cluster, use the following command:
kubectl apply -f k8s
![]() |
![]() |
![]() |
![]() |
![]() |
- 2021-05-31
peopleportal/passwords.json
deprecated.- Created
peopleportal/settings_common.py
to store all common configurations. peopleportal/setting.py
now contains only deployment specific configurations like db credentials, etc.- Removed
peopleportal/settings.py
. This should be manually created usingpeopleportal/settings__template__.py
. - Docker deployment
- Name: Gagandeep Singh
- Email: singh.gagan144@gmail.com
- Submitted on: October 2020