|
1 |
| -# Demo Devops Python |
| 1 | +# Demo DevOps Python Application |
2 | 2 |
|
3 |
| -This is a simple application to be used in the technical test of DevOps. |
| 3 | +Este repositorio contiene una simple aplicación Django que demuestra varias prácticas de DevOps. La aplicación se despliega en un clúster de Kubernetes utilizando Helm y GitHub Actions para los pipelines de CI/CD. |
4 | 4 |
|
5 |
| -## Getting Started |
| 5 | +## Table of Contents |
| 6 | +- [Arquitectura](#arquitectura) |
| 7 | +- [Instrucciones de Configuración](#instrucciones-de-configuración) |
| 8 | +- [Pipelines de CI/CD](#pipelines-de-ci-cd) |
| 9 | +- [Despliegue en Kubernetes](#despliegue-en-kubernetes) |
| 10 | +- [Infraestructura como Código](#infraestructura-como-código) |
| 11 | +- [Monitoreo y Logging](#monitoreo-y-logging) |
| 12 | +- [Contribuyendo](#contribuyendo) |
| 13 | +- [Licencia](#licencia) |
6 | 14 |
|
7 |
| -### Prerequisites |
| 15 | +## Arquitectura |
8 | 16 |
|
9 |
| -- Python 3.11.3 |
| 17 | +La API de Django se despliega en un clúster de Kubernetes con los siguientes componentes: |
| 18 | +- **Deployment**: La API se despliega con 2 réplicas, gestionadas por un Horizontal Pod Autoscaler (HPA) que puede escalar hasta 3 réplicas. |
| 19 | +- **Service Account**: Se utiliza una cuenta de servicio básica para seguir los estándares de seguridad. |
| 20 | +- **LoadBalancer**: Expone la API al mundo, accesible a través del dominio `https://api.algova.dev`. |
| 21 | +- **DNS y SSL**: Gestionados utilizando Route53 y Let's Encrypt. El dominio `api.algova.dev` apunta al LoadBalancer con renovación automática de certificados SSL. |
| 22 | +- **Archivos Estáticos**: Servidos desde un bucket de S3 con configuraciones ACL adecuadas. |
10 | 23 |
|
11 |
| -### Installation |
| 24 | + |
12 | 25 |
|
13 |
| -Clone this repo. |
| 26 | +## Instrucciones de Configuración |
14 | 27 |
|
15 |
| -```bash |
16 |
| -git clone https://bitbucket.org/devsu/demo-devops-python.git |
17 |
| -``` |
| 28 | +1. **Clonar el Repositorio**: |
| 29 | + ```bash |
| 30 | + git clone https://github.com/Adriana618/devops-deemo.git |
| 31 | + cd devops-deemo |
| 32 | + ``` |
18 | 33 |
|
19 |
| -Install dependencies. |
| 34 | +2. **Instalar Dependencias**: |
| 35 | + ```bash |
| 36 | + sudo apt-get update |
| 37 | + sudo apt-get install -y python3 python3-pip docker.io kubectl minikube |
| 38 | + pip3 install -r requirements.txt |
| 39 | + ``` |
20 | 40 |
|
21 |
| -```bash |
22 |
| -pip install -r requirements.txt |
23 |
| -``` |
| 41 | +3. **Dockerizar la Aplicación**: |
| 42 | + - Dockerfile ubicado en [`docker-conf/Dockerfile-django-api`](https://github.com/Adriana618/devops-deemo/blob/master/docker-conf/Dockerfile-django-api){:target="_blank"} |
24 | 43 |
|
25 |
| -Migrate database |
| 44 | +## Pipelines de CI/CD |
26 | 45 |
|
27 |
| -```bash |
28 |
| -py manage.py makemigrations |
29 |
| -py manage.py migrate |
30 |
| -``` |
| 46 | +### Deploy API |
| 47 | +Este GitHub Action despliega los commits mergeados en la rama `master` a un clúster de Kubernetes en DigitalOcean. |
31 | 48 |
|
32 |
| -### Database |
| 49 | +Ver el archivo [`.github/workflows/deploy.yml`](https://github.com/Adriana618/devops-deemo/blob/master/.github/workflows/deploy.yml){:target="_blank"} |
33 | 50 |
|
34 |
| -The database is generated as a file in the main path when the project is first run, and its name is `db.sqlite3`. |
| 51 | +### Test PR |
| 52 | +Este GitHub Action prueba las pull requests ejecutando análisis de código estático, cobertura de código y análisis de vulnerabilidades. |
35 | 53 |
|
36 |
| -Consider giving access permissions to the file for proper functioning. |
| 54 | +Ver el archivo [`.github/workflows/test-pr.yml`](https://github.com/Adriana618/devops-deemo/blob/master/.github/workflows/test-pr.yml){:target="_blank"} |
37 | 55 |
|
38 |
| -## Usage |
| 56 | +## Despliegue en Kubernetes |
39 | 57 |
|
40 |
| -To run tests you can use this command. |
| 58 | +### Configuración del Deployment |
| 59 | +Ver el archivo [`k8s/deployment.yaml`](https://github.com/Adriana618/devops-deemo/blob/master/k8s/deployment.yaml){:target="_blank"} |
41 | 60 |
|
42 |
| -```bash |
43 |
| -py manage.py test |
44 |
| -``` |
| 61 | +### Configuración del Service |
| 62 | +Ver el archivo [`k8s/service.yaml`](https://github.com/Adriana618/devops-deemo/blob/master/k8s/service.yaml){:target="_blank"} |
45 | 63 |
|
46 |
| -To run locally the project you can use this command. |
| 64 | +### ConfigMap y Secrets |
| 65 | +Ver los archivos [`k8s/configmap.yaml`](https://github.com/Adriana618/devops-deemo/blob/master/k8s/configmap.yaml){:target="_blank") y [`k8s/secret.yaml`](https://github.com/Adriana618/devops-deemo/blob/master/k8s/secret.yaml){:target="_blank"} |
47 | 66 |
|
48 |
| -```bash |
49 |
| -py manage.py runserver |
50 |
| -``` |
| 67 | +### Configuración de Ingress |
| 68 | +Ver el archivo [`k8s/ingress.yaml`](https://github.com/Adriana618/devops-deemo/blob/master/k8s/ingress.yaml){:target="_blank"} |
51 | 69 |
|
52 |
| -Open http://localhost:8000/api/ with your browser to see the result. |
| 70 | +## Infraestructura como Código |
53 | 71 |
|
54 |
| -### Features |
| 72 | +Usando Terraform, la infraestructura se provisiona en AWS: |
55 | 73 |
|
56 |
| -These services can perform, |
| 74 | +Ver el archivo [`terraform/main.tf`](https://github.com/Adriana618/devops-deemo/blob/master/terraform/main.tf){:target="_blank"} |
57 | 75 |
|
58 |
| -#### Create User |
| 76 | +## Monitoreo y Logging |
59 | 77 |
|
60 |
| -To create a user, the endpoint **/api/users/** must be consumed with the following parameters: |
| 78 | +La aplicación se monitorea usando Prometheus y Grafana, con logs centralizados en el stack ELK. |
61 | 79 |
|
62 |
| -```bash |
63 |
| - Method: POST |
64 |
| -``` |
| 80 | +## Contribuyendo |
65 | 81 |
|
66 |
| -```json |
67 |
| -{ |
68 |
| - "dni": "dni", |
69 |
| - "name": "name" |
70 |
| -} |
71 |
| -``` |
| 82 | +Por favor, sigue las [directrices de contribución](CONTRIBUTING.md) para proponer mejoras o reportar problemas. |
72 | 83 |
|
73 |
| -If the response is successful, the service will return an HTTP Status 200 and a message with the following structure: |
| 84 | +## Licencia |
74 | 85 |
|
75 |
| -```json |
76 |
| -{ |
77 |
| - "id": 1, |
78 |
| - "dni": "dni", |
79 |
| - "name": "name" |
80 |
| -} |
81 |
| -``` |
82 |
| - |
83 |
| -If the response is unsuccessful, we will receive status 400 and the following message: |
84 |
| - |
85 |
| -```json |
86 |
| -{ |
87 |
| - "detail": "error" |
88 |
| -} |
89 |
| -``` |
90 |
| - |
91 |
| -#### Get Users |
92 |
| - |
93 |
| -To get all users, the endpoint **/api/users** must be consumed with the following parameters: |
94 |
| - |
95 |
| -```bash |
96 |
| - Method: GET |
97 |
| -``` |
98 |
| - |
99 |
| -If the response is successful, the service will return an HTTP Status 200 and a message with the following structure: |
100 |
| - |
101 |
| -```json |
102 |
| -[ |
103 |
| - { |
104 |
| - "id": 1, |
105 |
| - "dni": "dni", |
106 |
| - "name": "name" |
107 |
| - } |
108 |
| -] |
109 |
| -``` |
110 |
| - |
111 |
| -#### Get User |
112 |
| - |
113 |
| -To get an user, the endpoint **/api/users/<id>** must be consumed with the following parameters: |
114 |
| - |
115 |
| -```bash |
116 |
| - Method: GET |
117 |
| -``` |
118 |
| - |
119 |
| -If the response is successful, the service will return an HTTP Status 200 and a message with the following structure: |
120 |
| - |
121 |
| -```json |
122 |
| -{ |
123 |
| - "id": 1, |
124 |
| - "dni": "dni", |
125 |
| - "name": "name" |
126 |
| -} |
127 |
| -``` |
128 |
| - |
129 |
| -If the user id does not exist, we will receive status 404 and the following message: |
130 |
| - |
131 |
| -```json |
132 |
| -{ |
133 |
| - "detail": "Not found." |
134 |
| -} |
135 |
| -``` |
136 |
| - |
137 |
| -## License |
138 |
| - |
139 |
| -Copyright © 2023 Devsu. All rights reserved. |
| 86 | +Este proyecto está licenciado bajo la Licencia MIT - ver el archivo [LICENSE](https://github.com/Adriana618/devops-deemo/blob/master/LICENSE){:target="_blank"} para más detalles. |
0 commit comments