Skip to content

Commit 49b3066

Browse files
authored
Merge pull request #2 from DevOps-and-Cloud-based-Software/1-reorganize-redmemd
fix #1
2 parents f99b09b + 8b5d3ab commit 49b3066

1 file changed

Lines changed: 33 additions & 49 deletions

File tree

README.md

Lines changed: 33 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,22 @@ In this tutorial will use GitOps practices with FastAPI including CI/CD pipeline
3737

3838
# 2. Tutorial
3939

40-
This tutorial will teach you:
41-
- Building REST APIs with FastAPI
42-
- Containerizing applications with Docker
43-
- Setting up CI/CD pipelines with GitHub Actions
44-
- Implementing code quality checks
45-
- Using pre-commit hooks for automated code validation
46-
- Following GitOps principles
40+
The steps of this tutorial are the following:
41+
- [Building REST APIs with FastAPI](#21-setting-up-the-project)
42+
- [Testing](#22-testing)
43+
- [Code Quality](#23-code-quality)
44+
- [Pre-commit Hooks](#24-pre-commit-hooks)
45+
- [Docker](#25-docker)
46+
- [Minikube Setup](#26-minikube-setup)
47+
- [Kubernetes Deployment with Helm](#27-kubernetes-deployment-with-helm)
4748

4849
Prerequisites:
4950
- Python 3.11 or higher
5051
- Git
5152
- Docker (optional, for containerization)
5253
- GitHub account
5354

54-
## Getting Started
55+
## 2.1 Setting Up the Project
5556
* Clone the Repository:
5657
```bash
5758
git clone https://github.com/DevOps-and-Cloud-based-Software/fastapi-gitops.git
@@ -88,7 +89,7 @@ Prerequisites:
8889
- List items: http://localhost:8000/GitOps-Starter/api/items
8990
- Get specific item: http://localhost:8000/GitOps-Starter/api/items/1
9091

91-
## Testing
92+
## 2.2 Testing
9293

9394
* Run Tests:
9495
```bash
@@ -102,7 +103,7 @@ Prerequisites:
102103

103104
* View the coverage report by opening `htmlcov/index.html` in your browser.
104105

105-
## Code Quality
106+
## 2.3 Code Quality
106107

107108
* Linting with Ruff:
108109

@@ -124,7 +125,7 @@ Prerequisites:
124125
black app/ tests/
125126
```
126127

127-
## Pre-commit Hooks
128+
## 2.4 Pre-commit Hooks
128129

129130
Pre-commit hooks automatically check your code before each commit, ensuring
130131
consistent code quality.
@@ -155,7 +156,7 @@ consistent code quality.
155156
- Trailing whitespace removal
156157
- End of file fixer
157158

158-
## Docker
159+
## 2.5 Docker
159160

160161
* Build the Docker Image:
161162
```bash
@@ -169,7 +170,7 @@ consistent code quality.
169170
```
170171
* Access the API at http://localhost:8000/GitOps-Starter/
171172

172-
## Minikube Setup
173+
## 2.6 Minikube Setup
173174

174175
If you want to test the Kubernetes deployment locally, you can use Minikube.
175176

@@ -192,7 +193,7 @@ If you want to test the Kubernetes deployment locally, you can use Minikube.
192193
Replace `<MINIKUBE_IP>` with the IP address obtained from the previous command.
193194

194195

195-
## Kubernetes Deployment with Helm
196+
## 2.7 Kubernetes Deployment with Helm
196197

197198
This repository includes a Helm chart for deploying the application to Kubernetes.
198199

@@ -217,7 +218,19 @@ Make sure you understand how to set up the Horizontal Pod Autoscaler (HPA) for
217218
scaling based on load and ingress configuration for accessing the application
218219
including host and paths.
219220

220-
## Exercise 1: Add pre-commit Hooks
221+
# 3. Exercises
222+
223+
## 3.0 Contributing
224+
225+
1. Fork the repository
226+
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
227+
3. Commit your changes (`git commit -m 'Add amazing feature'`)
228+
4. Push to the branch (`git push origin feature/amazing-feature`)
229+
5. Open a Pull Request
230+
6. Ensure all tests pass and code quality checks are successful
231+
7. Merge
232+
233+
## 3.1 Add pre-commit Hooks
221234
1. Open `.pre-commit-config.yaml`
222235
2. Add a new hook to check:
223236
* if we try to commit large files
@@ -227,9 +240,8 @@ including host and paths.
227240
* To make sure we do not commit secrets using
228241
* To check code style
229242

230-
231-
232-
## Exercise 2: Add a New Endpoint
243+
244+
## 3.2 Add a New Endpoint
233245

234246
1. Open `app/main.py`
235247
2. Add a new endpoint to create an item:
@@ -250,15 +262,15 @@ async def create_item(name: str, description: str):
250262
4. Run tests to verify
251263

252264

253-
## Exercise 3: Add a CI Pipeline
265+
## 3.3 Add a CI Pipeline
254266

255267
1. Open `.github/workflows/ci-cd.yml`
256268
2. Add a step to lint the code using Ruff
257269
3. Add a step to run tests with coverage. The pipeline should fail if coverage is below 80%
258270
4. Add a step to build the Docker image if tests pass. If we do a release, tag the image appropriately (with its version and the tag 'latest') and push it to GitHub registry
259271

260272

261-
## Exercise 4: Deploy on a K8s "production" Cluster
273+
## 3.4 Deploy on a K8s "production" Cluster
262274

263275
1. Set up a Kubernetes cluster (e.g., using Minikube or a cloud provider)
264276
2. Deploy the application using the Helm chart
@@ -273,35 +285,7 @@ kubectl get hpa -n default -w
273285
```
274286
7. Note how much time it takes for the pods to scale up and down based on the load
275287

276-
## Contributing
277-
278-
1. Fork the repository
279-
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
280-
3. Commit your changes (`git commit -m 'Add amazing feature'`)
281-
4. Push to the branch (`git push origin feature/amazing-feature`)
282-
5. Open a Pull Request
283-
6. Ensure all tests pass and code quality checks are successful
284-
7. Merge
285-
286-
## Tips
287-
288-
1. **Start Simple**: Understand each component before moving to the next
289-
2. **Read the Logs**: When something fails, the CI/CD logs contain valuable information
290-
291-
# 3 Questions
292-
293-
## Pre-commit Hooks
294-
1. How can pre-commit hooks improve code quality and consistency?
295-
2. How do you configure pre-commit hooks to run only on specific file types or directories?
296-
297-
## Code Coverage
298-
1. What are the benefits of maintaining high code coverage in a project?
299-
2. What other metrics can be used to assess code quality besides code coverage?
300-
301-
## CI/CD and Deployment
302-
1. What are some strategies for rolling back deployments in case of failures in the CI/CD pipeline?
303-
2. How can you set up automatic deployments in a production environment while minimizing downtime and ensuring KPOs are met?
288+
## 3.5 Questions
304289

305-
## Kubernetes and Helm
306290
1. The auto-scaling did not work as expected. What could be the possible reasons?
307291
2. How does Horizontal Pod Autoscaling (HPA) work in Kubernetes?

0 commit comments

Comments
 (0)