Skip to content

Commit c0ff917

Browse files
committed
Microservices - Initial commit.
1 parent 5607f34 commit c0ff917

34 files changed

+643
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ To establish a microservices-based platform that is scalable, maintainable, and
5353

5454
**Architecture Diagram:**
5555

56+
bash
57+
58+
```
5659
+----------------------+ +-----------------------+
5760
| Clients | | GitHub Codespaces |
5861
| (Browsers, Mobile) | | Dev Container |
@@ -81,6 +84,7 @@ v
8184
| Service Mesh |
8285
| (Istio) |
8386
+--------------+
87+
```
8488

8589
## Key Components:
8690

app/catalog/Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
FROM python:3.9-slim
3+
4+
WORKDIR /app
5+
6+
COPY requirements.txt /app/
7+
RUN pip install --no-cache-dir -r requirements.txt
8+
9+
COPY . /app/
10+
11+
EXPOSE 8000
12+
13+
CMD ["python", "app.py"]

app/catalog/app.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
from flask import Flask
3+
app = Flask(__name__)
4+
5+
@app.route("/")
6+
def hello():
7+
return "Catalog Service is Running!"
8+
9+
if __name__ == "__main__":
10+
app.run(host="0.0.0.0", port=8000)

app/catalog/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
flask==2.2.2

app/frontend/Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM python:3.11-slim
2+
3+
WORKDIR /app
4+
5+
COPY requirements.txt requirements.txt
6+
RUN pip install --no-cache-dir -r requirements.txt
7+
8+
COPY . .
9+
10+
CMD ["python", "app.py"]

app/frontend/app.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
from flask import Flask
3+
app = Flask(__name__)
4+
5+
@app.route("/")
6+
def hello():
7+
return "Frontend Service is Running!"
8+
9+
if __name__ == "__main__":
10+
app.run(host="0.0.0.0", port=80)

app/frontend/k8s/deployment.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: frontend-service
5+
namespace: ecommerce
6+
spec:
7+
replicas: 3
8+
selector:
9+
matchLabels:
10+
app: frontend-service
11+
template:
12+
metadata:
13+
labels:
14+
app: frontend-service
15+
spec:
16+
containers:
17+
- name: frontend-service
18+
image: egitangu/frontend-service:latest
19+
ports:
20+
- containerPort: 8004
21+
resources:
22+
limits:
23+
cpu: "500m"
24+
memory: "128Mi"
25+
requests:
26+
cpu: "200m"
27+
memory: "64Mi"
28+
env:
29+
- name: RABBITMQ_HOST
30+
value: rabbitmq

app/frontend/k8s/hpa.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: autoscaling/v2
2+
kind: HorizontalPodAutoscaler
3+
metadata:
4+
name: frontend-hpa
5+
namespace: ecommerce
6+
spec:
7+
scaleTargetRef:
8+
apiVersion: apps/v1
9+
kind: Deployment
10+
name: frontend-service
11+
minReplicas: 2
12+
maxReplicas: 10
13+
metrics:
14+
- type: Resource
15+
resource:
16+
name: cpu
17+
target:
18+
type: Utilization
19+
averageUtilization: 50

app/frontend/k8s/service.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: frontend-service
5+
namespace: ecommerce
6+
spec:
7+
ports:
8+
- port: 8004
9+
targetPort: 8004
10+
selector:
11+
app: frontend-service

app/frontend/requirements.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Flask==2.2.3
2+
pika==1.3.0
3+
prometheus-client==0.16.0
4+
requests==2.31.0
5+
python-dotenv==1.0.0
6+
gunicorn==20.1.0

0 commit comments

Comments
 (0)