Skip to content

Commit 648c541

Browse files
committed
feat: kubernetes support
1 parent 269f0aa commit 648c541

File tree

7 files changed

+150
-18
lines changed

7 files changed

+150
-18
lines changed

kubernetes/backend-deployment.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: backend-deployment
5+
spec:
6+
replicas: 2 # minimum replicas for HPA
7+
selector:
8+
matchLabels:
9+
app: backend
10+
template:
11+
metadata:
12+
labels:
13+
app: backend
14+
spec:
15+
containers:
16+
- name: backend
17+
image: aayushxrj/gochat-backend:latest
18+
ports:
19+
- containerPort: 8080
20+
resources:
21+
requests:
22+
cpu: "200m"
23+
memory: "256Mi"
24+
limits:
25+
cpu: "500m"
26+
memory: "512Mi"
27+
28+
---
29+
apiVersion: v1
30+
kind: Service
31+
metadata:
32+
name: backend-service
33+
spec:
34+
selector:
35+
app: backend
36+
ports:
37+
- protocol: TCP
38+
port: 8080
39+
targetPort: 8080
40+
type: ClusterIP

kubernetes/backend-hpa.yaml

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

kubernetes/backend-vpa.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: autoscaling.k8s.io/v1
2+
kind: VerticalPodAutoscaler
3+
metadata:
4+
name: backend-vpa
5+
spec:
6+
targetRef:
7+
apiVersion: "apps/v1"
8+
kind: Deployment
9+
name: backend-deployment
10+
updatePolicy:
11+
updateMode: "Off" # Set to "Auto" for automatic updates(Overrides HPA limits), "Off" to disable updates

kubernetes/busybox.yaml

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: frontend-deployment
5+
spec:
6+
replicas: 2 # start with min 2
7+
selector:
8+
matchLabels:
9+
app: frontend
10+
template:
11+
metadata:
12+
labels:
13+
app: frontend
14+
spec:
15+
containers:
16+
- name: frontend
17+
image: aayushxrj/gochat-frontend:latest
18+
ports:
19+
- containerPort: 5173
20+
resources:
21+
requests:
22+
cpu: "100m"
23+
memory: "128Mi"
24+
limits:
25+
cpu: "300m"
26+
memory: "256Mi"
27+
28+
---
29+
apiVersion: v1
30+
kind: Service
31+
metadata:
32+
name: frontend-service
33+
spec:
34+
selector:
35+
app: frontend
36+
ports:
37+
- protocol: TCP
38+
port: 5173
39+
targetPort: 5173
40+
type: NodePort

kubernetes/frontend-hpa.yaml

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

kubernetes/frontend-vpa.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: autoscaling.k8s.io/v1
2+
kind: VerticalPodAutoscaler
3+
metadata:
4+
name: frontend-vpa
5+
spec:
6+
targetRef:
7+
apiVersion: "apps/v1"
8+
kind: Deployment
9+
name: frontend-deployment
10+
updatePolicy:
11+
updateMode: "Off" # Set to "Auto" for automatic updates(Overrides HPA limits), "Off" to disable updates

0 commit comments

Comments
 (0)