Skip to content

Commit 30fff61

Browse files
committed
infra: reorganize k8s manifests and update terraform for eks/alb autoscaling
1 parent 50a3070 commit 30fff61

24 files changed

Lines changed: 707 additions & 542 deletions

.DS_Store

-6 KB
Binary file not shown.

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
11
node_modules/
22
dist/
33
*.env*
4+
# Terraform
5+
.terraform/
6+
*.tfstate
7+
*.tfstate.*
8+
*.tfvars
9+
# macOS
10+
.DS_Store
11+
# K8s secrets (local only)
12+
ops/secrets.yaml

k8s/secrets.yaml

Lines changed: 0 additions & 24 deletions
This file was deleted.

k8s/README.md renamed to ops/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,26 +87,26 @@ kubectl get ingress -n calcom
8787
kubectl get ingress -n calcom -o jsonpath='{.items[0].status.loadBalancer.ingress[0].hostname}'
8888

8989
# Check logs
90-
kubectl logs -n calcom -l app=calcom-api --tail=100
90+
kubectl logs -n calcom -l app=nodejs-api --tail=100
9191
```
9292

9393
## Useful Commands
9494

9595
```bash
9696
# Scale manually
97-
kubectl scale deployment calcom-api -n calcom --replicas=5
97+
kubectl scale deployment nodejs-api -n calcom --replicas=5
9898

9999
# Restart deployment (rolling update)
100-
kubectl rollout restart deployment calcom-api -n calcom
100+
kubectl rollout restart deployment nodejs-api -n calcom
101101

102102
# Check rollout status
103-
kubectl rollout status deployment calcom-api -n calcom
103+
kubectl rollout status deployment nodejs-api -n calcom
104104

105105
# Rollback
106-
kubectl rollout undo deployment calcom-api -n calcom
106+
kubectl rollout undo deployment nodejs-api -n calcom
107107

108108
# Port forward for local testing
109-
kubectl port-forward -n calcom svc/calcom-api 8080:80
109+
kubectl port-forward -n calcom svc/nodejs-api 8080:80
110110
```
111111

112112
## Architecture
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
apiVersion: v1
22
kind: ConfigMap
33
metadata:
4-
name: calcom-config
5-
namespace: calcom
4+
name: nodejs-config
5+
# namespace: calcom
66
data:
77
NODE_ENV: "production"
8-
API_PORT: "80"
8+
API_PORT: "3000"
99
LOG_LEVEL: "info"
1010
API_KEY_PREFIX: "cal_"
1111

12-
# URLs - update with your domain
1312
NEXT_PUBLIC_WEBAPP_URL: "https://app.yourdomain.com"
1413
NEXT_PUBLIC_API_V2_URL: "https://api.yourdomain.com"
1514

16-
# Feature flags
1715
IS_E2E: "false"
Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,55 @@
11
apiVersion: apps/v1
22
kind: Deployment
33
metadata:
4-
name: calcom-api
5-
namespace: calcom
4+
name: nodejs-api
5+
# namespace: calcom
66
labels:
7-
app: calcom-api
7+
app: nodejs-api
88
spec:
99
replicas: 2
1010
selector:
1111
matchLabels:
12-
app: calcom-api
12+
app: nodejs-api
1313
template:
1414
metadata:
1515
labels:
16-
app: calcom-api
16+
app: nodejs-api
1717
spec:
1818
containers:
1919
- name: api
20-
image: chauhansomay/calcom-api-v2:latest
20+
image: chauhansomay/nodejs-api:latest
2121
imagePullPolicy: Always
2222
ports:
23-
- containerPort: 80
23+
- containerPort: 3000
2424
protocol: TCP
2525

2626
envFrom:
2727
- configMapRef:
28-
name: calcom-config
28+
name: nodejs-config
2929
- secretRef:
30-
name: calcom-secrets
30+
name: nodejs-secrets
3131

3232
resources:
3333
requests:
34-
cpu: "250m"
35-
memory: "512Mi"
34+
cpu: "100m"
35+
memory: "128Mi"
3636
limits:
37-
cpu: "1000m"
38-
memory: "1Gi"
37+
cpu: "500m"
38+
memory: "256Mi"
3939

4040
livenessProbe:
4141
httpGet:
42-
path: /api/health
43-
port: 80
42+
path: /health
43+
port: 3000
4444
initialDelaySeconds: 30
4545
periodSeconds: 10
4646
timeoutSeconds: 5
4747
failureThreshold: 3
4848

4949
readinessProbe:
5050
httpGet:
51-
path: /api/health
52-
port: 80
51+
path: /health
52+
port: 3000
5353
initialDelaySeconds: 10
5454
periodSeconds: 5
5555
timeoutSeconds: 3
@@ -62,4 +62,4 @@ spec:
6262
whenUnsatisfiable: ScheduleAnyway
6363
labelSelector:
6464
matchLabels:
65-
app: calcom-api
65+
app: nodejs-api

k8s/hpa.yaml renamed to ops/hpa.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
apiVersion: autoscaling/v2
22
kind: HorizontalPodAutoscaler
33
metadata:
4-
name: calcom-api-hpa
5-
namespace: calcom
4+
name: nodejs-api-hpa
5+
# namespace: calcom
66
spec:
77
scaleTargetRef:
88
apiVersion: apps/v1
99
kind: Deployment
10-
name: calcom-api
10+
name: nodejs-api
1111

1212
minReplicas: 2
13-
maxReplicas: 10
13+
maxReplicas: 30
1414

1515
metrics:
1616
# Scale based on CPU
Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
11
apiVersion: networking.k8s.io/v1
22
kind: Ingress
33
metadata:
4-
name: calcom-api
5-
namespace: calcom
4+
name: nodejs-api
5+
# namespace: calcom
66
annotations:
7-
# Use AWS ALB Ingress Controller
8-
kubernetes.io/ingress.class: alb
9-
10-
# ALB Configuration
7+
# ALB Configuration - EKS Auto Mode auto-discovers subnets
118
alb.ingress.kubernetes.io/scheme: internet-facing
129
alb.ingress.kubernetes.io/target-type: ip
1310

14-
# Subnets - REPLACE with output from: terraform output public_subnet_ids
15-
alb.ingress.kubernetes.io/subnets: subnet-xxxxx,subnet-yyyyy
16-
1711
# Health check
18-
alb.ingress.kubernetes.io/healthcheck-path: /api/health
12+
alb.ingress.kubernetes.io/healthcheck-path: /health
1913
alb.ingress.kubernetes.io/healthcheck-interval-seconds: "30"
2014
alb.ingress.kubernetes.io/healthy-threshold-count: "2"
2115
alb.ingress.kubernetes.io/unhealthy-threshold-count: "2"
@@ -29,16 +23,17 @@ metadata:
2923
# alb.ingress.kubernetes.io/ssl-redirect: "443"
3024

3125
# Tags for the ALB
32-
alb.ingress.kubernetes.io/tags: Environment=production,App=calcom
26+
alb.ingress.kubernetes.io/tags: Environment=production,App=nodejs-api
3327

3428
spec:
29+
ingressClassName: alb
3530
rules:
3631
- http:
3732
paths:
3833
- path: /
3934
pathType: Prefix
4035
backend:
4136
service:
42-
name: calcom-api
37+
name: nodejs-api-service
4338
port:
4439
number: 80

ops/migration-job.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
apiVersion: batch/v1
2+
kind: Job
3+
metadata:
4+
name: prisma-migrate
5+
spec:
6+
backoffLimit: 0
7+
template:
8+
spec:
9+
containers:
10+
- name: migrate
11+
image: chauhansomay/nodejs-api:latest
12+
command:
13+
- /bin/sh
14+
- -c
15+
- |
16+
echo "Running prisma migrate..."
17+
npx prisma db push || echo "Migration failed"
18+
echo "Sleeping for debugging..."
19+
sleep 3600
20+
envFrom:
21+
- configMapRef:
22+
name: nodejs-config
23+
- secretRef:
24+
name: nodejs-secrets
25+
restartPolicy: Never
File renamed without changes.

0 commit comments

Comments
 (0)