Skip to content

Commit

Permalink
Merge pull request #157 from CS3219-AY2425S1/feat/add-health-check-se…
Browse files Browse the repository at this point in the history
…ssion

add health check session
  • Loading branch information
tyouwei authored Nov 9, 2024
2 parents f2cdbb1 + e986b68 commit 33fa190
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 20 deletions.
22 changes: 18 additions & 4 deletions k8s/api-gateway.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,36 @@ spec:
imagePullPolicy: Always
resources:
requests:
cpu: "500m"
memory: "512Mi"
memory: "128Mi"
cpu: "100m"
limits:
cpu: "1"
memory: "1Gi"
memory: "256Mi"
cpu: "200m"
ports:
- containerPort: 8001
envFrom:
- secretRef:
name: api-gateway-config
livenessProbe: # Add this block for liveness probe
httpGet:
path: /
port: 8001
initialDelaySeconds: 10
periodSeconds: 10
readinessProbe: # Add this block for readiness probe
httpGet:
path: /
port: 8001
initialDelaySeconds: 5
periodSeconds: 5
dnsPolicy: ClusterFirst
---
apiVersion: v1
kind: Service
metadata:
name: api-gateway
annotations:
cloud.google.com/neg: '{"ingress": true}'
spec:
type: LoadBalancer
ports:
Expand Down
65 changes: 52 additions & 13 deletions k8s/ingress.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,61 @@
apiVersion: networking.gke.io/v1beta1
kind: FrontendConfig
metadata:
name: http-to-https
spec:
redirectToHttps:
enabled: true
responseCodeName: MOVED_PERMANENTLY_DEFAULT
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: fe-ingress
name: nginx-ingress-session
annotations:
ingress.kubernetes.io/rewrite-target: /
kubernetes.io/ingress.global-static-ip-name: nginx-api
networking.gke.io/managed-certificates: peerprep-fe-cs3219-g11-nginx-all
kubernetes.io/ingress.class: "gce"
networking.gke.io/frontend-config: "http-to-https"
spec:
tls:
- hosts:
- peerprep-interview.duckdns.org
secretName: peerprep-config
ingressClassName: "gce"
rules:
- host: peerprep-interview.duckdns.org
- host: peerprep-fe.duckdns.org
http:
paths:
- path: /
pathType: Prefix
backend:
service:
paths:
- path: /*
pathType: ImplementationSpecific
backend:
service:
name: peerprep-fe
port:
number: 80
number: 80
- host: peerprep-api.duckdns.org
http:
paths:
- path: /*
pathType: ImplementationSpecific
backend:
service:
name: api-gateway
port:
number: 8001
- host: peerprep-session.duckdns.org
http:
paths:
- path: /*
pathType: ImplementationSpecific
backend:
service:
name: session-svc
port:
number: 4444
- host: peerprep-audio.duckdns.org
http:
paths:
- path: /*
pathType: ImplementationSpecific
backend:
service:
name: session-svc
port:
number: 5555
10 changes: 10 additions & 0 deletions k8s/managed-cert.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: networking.gke.io/v1
kind: ManagedCertificate
metadata:
name: peerprep-fe-cs3219-g11-nginx-all
spec:
domains:
- peerprep-mock-interview.duckdns.org
- peerprep-api.duckdns.org
- peerprep-session.duckdns.org
- peerprep-audio.duckdns.org
10 changes: 8 additions & 2 deletions k8s/peerprep-fe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ metadata:
spec:
type: LoadBalancer
ports:
- port: 80
- name: http
protocol: TCP
port: 80
targetPort: 3000
- name: https
protocol: TCP
port: 443
targetPort: 3000
selector:
type: frontend
Expand Down Expand Up @@ -76,4 +82,4 @@ stringData:
NEXT_PUBLIC_API_GATEWAY_URL: "${_NEXT_PUBLIC_API_GATEWAY_URL}"
NEXT_PUBLIC_GITHUB_CLIENT_ID: "${_NEXT_PUBLIC_GITHUB_CLIENT_ID}"
NEXT_PUBLIC_SOCK_SERVER_URL: "${_NEXT_PUBLIC_SOCK_SERVER_URL}"
NEXT_PUBLIC_AUDIO_SERVER_URL: "${_NEXT_PUBLIC_AUDIO_SERVER_URL}"
NEXT_PUBLIC_AUDIO_SERVER_URL: "${_NEXT_PUBLIC_AUDIO_SERVER_URL}"
5 changes: 5 additions & 0 deletions session-service/src/audio-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ app.use(
})
);

// Health check route
app.get('/', (req, res) => {
res.status(200).send('OK');
});

const httpServer = createServer(app);
const io = new Server(httpServer, {
cors: {
Expand Down
7 changes: 6 additions & 1 deletion session-service/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ app.use(
credentials: true,
})
);
app.use(express.json()); //
app.use(express.json());

// Health check route
app.get('/', (req, res) => {
res.status(200).send('OK');
});

/**
* Create an http server
Expand Down

0 comments on commit 33fa190

Please sign in to comment.