Welcome to the DevOpsDemo repository! This project is a comprehensive example that demonstrates various aspects of modern web development, including Django-based application development, Docker containerization, Ansible automation, Jenkins CI/CD integration, and Kubernetes deployment.
- Begin by cloning this repository to your local machine.
- Navigate to the root directory of the project.
- Create a virtual environment:
python3 -m venv .venv
and activate it:source .venv/bin/activate
. - Install dependencies:
pip install -r requirements.txt
. - Apply database migrations:
python manage.py migrate
. - Start the development server:
python manage.py runserver
.
- Make sure Docker is installed on your machine. (You can install Docker with ansible docker-playbook)
- Build and Run:
docker-compose up -d --build
- Ensure you have a functioning Kubernetes cluster.
- Deploy to Kubernetes:
kubectl apply -f k8s/
.
The Jenkinsfile
defines the CI/CD pipeline orchestrated by Jenkins (Dockerized Deployment). This pipeline encompasses the following stages:
- Checkout: Fetch the latest code from the repository.
- Build and Run Containers: Construct or pull Docker images and run those in containers.
- Run Tests: Execute tests within the Docker container.
- Deploy to Docker Hub: Push the Docker image to Docker Hub for distribution.
The ansible/
directory holds Ansible playbooks for automating tasks on the host machine. Specifically:
-
The
docker-playbook.yml
playbook ensures Docker is installed on the host machine. Execute it using:ansible-playbook ansible/docker-playbook.yml
. -
The
nginx-playbook.yml
playbook installs NGINX on the host machine if absent. Run the playbook using:ansible-playbook ansible/nginx-playbook.yml
.
The nginx.conf
file serves as a customizable NGINX configuration template. Customize it to meet your specific requirements before copying it to /etc/nginx/sites-available/
on your host machine.
For development environment, the .env.dev
file is used to store environment-specific settings. Customize this file to define variables such as database configurations and secret keys that your Django application requires.
This project is intended for educational and practical purposes only. It serves as a learning exercise and does not have any commercial or production intent. The primary goal of this project is to provide hands-on experience and demonstrate various concepts, techniques, and skills in a real-world scenario.