You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
then open a browser and navigate to http://localhost:8000. If it opens "Hello world", then it works.
26
+
Then open a browser and navigate to http://localhost:8000. If it opens "Hello world", then it works.
27
27
28
28
## Workflows
29
29
30
-
Two workflows are available in the project. One should trigger on pull request and another one on merge. A workflow,
31
-
which triggers on push is not created, as it may cost a lot of resources and go over the budget.
30
+
Two workflows are available in the project. One triggers on pull requests, and another triggers on merges. A workflow that triggers on every push is not created, as it may consume excessive resources and exceed the budget.
32
31
33
-
To run ***fastapi_merge.yml*** workflow, a pull request should be made to the main branch and merged to GitHub.
34
-
It will trigger the pipeline and can be seen in GitHub -> Actions tab. The workflow includes the following checks:
35
-
SonarCloud, Snyk, Trivy. It also builds the Docker image and push it to DockerHub.
32
+
### **Pull Request Workflow**
33
+
To run the ***fastapi_pr.yml*** pipeline, a pull request should be made to the main branch on GitHub. This will trigger the pipeline, which can be monitored in the GitHub -> Actions tab. The workflow includes the following checks:
34
+
-**GitLeaks**: Scans for sensitive information in the codebase.
-**Python PyLint**: Checks for Python code quality.
37
+
-**Python Black**: Formats Python code to adhere to PEP 8 standards.
38
+
-**MarkdownLint CLI**: Validates Markdown files for proper formatting.
39
+
-**Unit Tests**: Runs the test suite to ensure code correctness.
36
40
37
-
To run ***fastapi_pr.yml*** pipeline, a pull request should be made to the main branch to GitHub.
38
-
It will trigger the pipeline and can be seen in GitHub -> Actions tab. The workflow includes the following checks:
39
-
GitLeaks, EditConfig, Python PyLint, Python Black, MarkdownLint CLI, Unit tests.
41
+
### **Merge Workflow**
42
+
To run the ***fastapi_merge.yml*** workflow, a pull request should be merged into the main branch on GitHub. This will trigger the pipeline, which can also be monitored in the GitHub -> Actions tab. The workflow includes the following steps:
43
+
-**SonarCloud**: Performs static code analysis for code quality and security.
44
+
-**Snyk**: Scans for vulnerabilities in dependencies.
45
+
-**Trivy**: Scans Docker images for vulnerabilities.
46
+
-**Docker Image Build and Push**: Builds the Docker image and pushes it to Docker Hub.
40
47
41
48
## ArgoCD
42
49
43
-
Prerequisites:
44
-
-installed***kubectl*** command-line tool
45
-
-installed***Docker Desktop*** or other external cluster
50
+
### Prerequisites
51
+
-Installed***kubectl*** command-line tool.
52
+
-Installed***Docker Desktop*** or another external Kubernetes cluster.
46
53
47
54
### Install ArgoCD
48
-
55
+
To install ArgoCD, create a namespace for it:
49
56
```shell
50
57
kubectl create namespace argocd
51
58
```
52
-
53
-
This will create a new namespace server, where Argo CD services and application resources will live.
If the application's health status is "Out of sync," click the 'Sync apps' button in the UI. Then, click 'Synchronize' to deploy the application. You can view more details by clicking on the application.
92
103
93
-
If it's Health status is 'Out of sync', then click on the 'Sync apps' button in the application page UI. A panel will be
94
-
opened and then, click on 'Synchronize' button.
95
-
You can see more details by clicking at the 'app' application.
104
+
## Kubernetes Deployment
96
105
97
-
## Kubernetes deployment
106
+
The deployment files are stored in a separate GitOps repository: [https://github.com/boyanaboneva/devops-gitops](https://github.com/boyanaboneva/devops-gitops).
98
107
99
-
Deployments files are in another repo: https://github.com/boyanaboneva/devops-gitops
100
-
101
-
Create another namespace, e.g. 'application':
108
+
### Create a Namespace
109
+
Create a namespace for the application:
102
110
```shell
103
111
kubectl create namespace application
104
112
```
105
113
106
-
To create a config map with environment variables navigate to the file in the gitops repo via terminal:
114
+
### Apply ConfigMap
115
+
Navigate to the GitOps repository and apply the environment variables ConfigMap:
107
116
```shell
108
117
kubectl apply -f env_fastapi_configmap.yml
109
118
```
110
119
111
-
Using terminal navigate to the kubernetes deployment folder in the gitops repo. Apply the 'deployment.yml' file in the
112
-
newly created namespace, e.g. 'application':
120
+
### Apply Deployment
121
+
Navigate to the Kubernetes deployment folder in the GitOps repository and apply the deployment manifest:
113
122
```shell
114
123
kubectl apply -f deployment.yml -n application
115
124
```
116
-
The response should look like this:
125
+
Expected response:
117
126
```shell
118
127
deployment.apps/fast-api-deployment created
119
128
```
120
129
121
-
To check everything is applied, get the pods of this namespace:
This project follows a modern DevOps architecture that integrates **GitHub**, **GitHub Actions**, **ArgoCD**, **Docker Hub**, and **Kubernetes**. Below is a detailed explanation of the architecture:
154
+
155
+
### Key Components
156
+
1.**GitHub**: Hosts the application code and a separate GitOps repository for Kubernetes manifests.
157
+
2.**GitHub Actions**: Automates CI/CD workflows, including building, testing, and pushing Docker images.
158
+
3.**Docker Hub**: Stores Docker images for deployment.
159
+
4.**Kubernetes**: Orchestrates containerized applications, ensuring scalability and reliability.
160
+
5.**ArgoCD**: Implements GitOps principles by syncing Kubernetes manifests from the GitOps repository to the cluster.
161
+
162
+
### Workflow Summary
163
+
1. Developers push code changes to GitHub.
164
+
2. GitHub Actions builds the application, runs tests, and pushes Docker images to Docker Hub.
165
+
3. The GitOps repository is updated with the new image tag in the Kubernetes manifests.
166
+
4. ArgoCD detects changes in the GitOps repository and syncs them to the Kubernetes cluster.
167
+
168
+
This architecture ensures a seamless CI/CD pipeline with automated deployments, version control, and rollback capabilities.
0 commit comments