Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-add ingress files to prod #201

Merged
merged 21 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
8167cac
Downsize prod CPU requests
yhtMinceraft1010X Oct 24, 2023
c1ff1fa
Re-arrange frontend dependencies
yhtMinceraft1010X Oct 25, 2023
ae0c485
Clear timeout in useEffect (#174)
chunweii Oct 26, 2023
0f81576
Fix gateway user verification (#186)
yhtMinceraft1010X Oct 26, 2023
36f73b0
Fix websocket proxying bug (#183)
yhtMinceraft1010X Oct 26, 2023
043f6ff
Fix missing env variables in Docker Compose
yhtMinceraft1010X Oct 26, 2023
38eefe3
Add HTTPS support and reconfigure ingress
yhtMinceraft1010X Oct 26, 2023
f87dbb8
Fix service name errors
yhtMinceraft1010X Oct 26, 2023
86ded76
Fix gateway being named frontend
yhtMinceraft1010X Oct 26, 2023
4b7f557
Merge branch 'prod' into master
yhtMinceraft1010X Oct 26, 2023
90af990
Add server-side search for question title and filtering by difficulty…
chunweii Oct 26, 2023
f3edc05
Remove unused FQDN from managed cert
yhtMinceraft1010X Oct 27, 2023
3ac8c2f
Add backend config to Gateway service
yhtMinceraft1010X Oct 27, 2023
548cde1
Fix CORS response headers
yhtMinceraft1010X Oct 27, 2023
50f08f2
Merge branch 'prod' into master
yhtMinceraft1010X Oct 27, 2023
f575671
Revert back to HTTP with loadbalancer services
yhtMinceraft1010X Oct 27, 2023
036f2e1
Remove backend config
yhtMinceraft1010X Oct 27, 2023
c641a3d
Revert "Revert back to HTTP with loadbalancer services"
yhtMinceraft1010X Oct 27, 2023
6629bbe
Add healthcheck on gateway
yhtMinceraft1010X Oct 27, 2023
b919b3a
Merge branch 'prod' into master
yhtMinceraft1010X Oct 27, 2023
53f9e88
Revert "Merge branch 'prod' into master"
yhtMinceraft1010X Oct 27, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions deployment/gke-prod-manifests/frontend-ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: frontend-ingress
annotations:
networking.gke.io/managed-certificates: gke-managed-cert
kubernetes.io/ingress.class: "gce"
spec:
defaultBackend:
service:
name: frontend
port:
number: 3000
1 change: 0 additions & 1 deletion deployment/gke-prod-manifests/frontend-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,5 @@ spec:
targetPort: 3000
selector:
io.kompose.service: frontend
type: LoadBalancer
status:
loadBalancer: {}
4 changes: 2 additions & 2 deletions deployment/gke-prod-manifests/gateway-backend-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ spec:
healthCheck:
timeoutSec: 3
type: HTTP
requestPath: /healthz
port: 8080
requestPath: /healthcheck
port: 4000
customResponseHeaders:
headers:
- "Access-Control-Allow-Origin: https://www.codeparty.org"
Expand Down
6 changes: 5 additions & 1 deletion deployment/gke-prod-manifests/gateway-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ spec:
- name: WS_COLLABORATION_PROXY_PORT
value: "4003"
- name: FRONTEND_ADDRESS
value: "http://www.codeparty.org"
value: "https://www.codeparty.org"
image: asia-southeast1-docker.pkg.dev/peerprep-group11-prod/codeparty-prod-images/gateway:latest
name: gateway
ports:
Expand All @@ -44,6 +44,10 @@ spec:
- containerPort: 4003
hostPort: 4003
protocol: TCP
# Needed for health check
- containerPort: 8080
hostPort: 8080
protocol: TCP
resources:
# You must specify requests for CPU to autoscale
# based on CPU utilization
Expand Down
13 changes: 13 additions & 0 deletions deployment/gke-prod-manifests/gateway-http-ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: gateway-http-ingress
annotations:
networking.gke.io/managed-certificates: gke-managed-cert
kubernetes.io/ingress.class: "gce"
spec:
defaultBackend:
service:
name: gateway
port:
number: 4000
1 change: 0 additions & 1 deletion deployment/gke-prod-manifests/gateway-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,5 @@ spec:
targetPort: 8080
selector:
io.kompose.service: gateway
type: LoadBalancer
status:
loadBalancer: {}
13 changes: 13 additions & 0 deletions deployment/gke-prod-manifests/gateway-wscollaboration-ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: gateway-wscollaboration-ingress
annotations:
networking.gke.io/managed-certificates: gke-managed-cert
kubernetes.io/ingress.class: "gce"
spec:
defaultBackend:
service:
name: gateway
port:
number: 4003
13 changes: 13 additions & 0 deletions deployment/gke-prod-manifests/gateway-wsmatch-ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: gateway-wsmatch-ingress
annotations:
networking.gke.io/managed-certificates: gke-managed-cert
kubernetes.io/ingress.class: "gce"
spec:
defaultBackend:
service:
name: gateway
port:
number: 4002
10 changes: 10 additions & 0 deletions deployment/gke-prod-manifests/gke-managed-cert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: networking.gke.io/v1
kind: ManagedCertificate
metadata:
name: gke-managed-cert
spec:
domains:
- www.codeparty.org
- api.codeparty.org
- wsmatch.codeparty.org
- wscollab.codeparty.org
6 changes: 3 additions & 3 deletions deployment/prod-dockerfiles/Dockerfile.frontend-prod
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ RUN yarn prisma generate
ARG NEXT_PUBLIC_FRONTEND_FIREBASE_CONFIG_ARG
ENV NEXT_PUBLIC_FRONTEND_FIREBASE_CONFIG=$NEXT_PUBLIC_FRONTEND_FIREBASE_CONFIG_ARG

ENV NEXT_PUBLIC_HTTP_PROXY_GATEWAY_ADDRESS="http://api.codeparty.org:4000/"
ENV NEXT_PUBLIC_WS_MATCH_PROXY_GATEWAY_ADDRESS="http://api.codeparty.org:4002"
ENV NEXT_PUBLIC_WS_COLLABORATION_PROXY_GATEWAY_ADDRESS="http://api.codeparty.org:4003"
ENV NEXT_PUBLIC_HTTP_PROXY_GATEWAY_ADDRESS="https://api.codeparty.org/"
ENV NEXT_PUBLIC_WS_MATCH_PROXY_GATEWAY_ADDRESS="https://wsmatch.codeparty.org"
ENV NEXT_PUBLIC_WS_COLLABORATION_PROXY_GATEWAY_ADDRESS="https://wscollab.codeparty.org"

RUN yarn build

Expand Down
2 changes: 2 additions & 0 deletions services/gateway/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
"dependencies": {
"cors": "^2.8.5",
"dotenv": "^16.3.1",
"express-healthcheck": "^0.1.0",
"firebase-admin": "^11.10.1",
"http-proxy-middleware": "^2.0.6",
"morgan": "^1.10.0"
},
"devDependencies": {
"@types/cors": "^2.8.14",
"@types/express-healthcheck": "^0.1.2",
"@types/morgan": "^1.9.6",
"swagger-autogen": "^2.23.6",
"ts-node-dev": "^2.0.0",
Expand Down
4 changes: 4 additions & 0 deletions services/gateway/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { setupProxies } from "./proxy/proxy";
import {http_proxied_routes, wsCollaborationProxiedRoutes, wsMatchProxiedRoutes} from "./proxied_routes/proxied_routes";
import {frontendAddress} from "./proxied_routes/service_names";
import {createProxyMiddleware} from "http-proxy-middleware";
import healthCheck from "express-healthcheck";


const httpApp : Express = express();
Expand All @@ -25,6 +26,9 @@ httpApp.use(cors(corsOptions));
wsMatchApp.use(cors(corsOptions));
wsCollaborationApp.use(cors(corsOptions));

// Health check
httpApp.use('/healthcheck', healthCheck());

/**
* WARNING: Do not add body parsing middleware to the Gateway.
* Otherwise, proxying POST requests with request body would not work.
Expand Down
12 changes: 12 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3059,6 +3059,13 @@
dependencies:
"@types/node" "*"

"@types/express-healthcheck@^0.1.2":
version "0.1.2"
resolved "https://registry.yarnpkg.com/@types/express-healthcheck/-/express-healthcheck-0.1.2.tgz#1f1aa8846d5e0fb9f71a9acad8ac2f1806bf6fd6"
integrity sha512-enSA1JuIErGJqfCCDmNAq6N8OIBhgdg+mBvHUOTrjy7zdrDEKJ4sJr97MoFZNIDh32bUII1F+uPmqgC9H8b4mQ==
dependencies:
"@types/express" "*"

"@types/express-serve-static-core@^4.17.33":
version "4.17.39"
resolved "https://registry.yarnpkg.com/@types/express-serve-static-core/-/express-serve-static-core-4.17.39.tgz#2107afc0a4b035e6cb00accac3bdf2d76ae408c8"
Expand Down Expand Up @@ -6050,6 +6057,11 @@ exponential-backoff@^3.1.1:
resolved "https://registry.yarnpkg.com/exponential-backoff/-/exponential-backoff-3.1.1.tgz#64ac7526fe341ab18a39016cd22c787d01e00bf6"
integrity sha512-dX7e/LHVJ6W3DE1MHWi9S1EYzDESENfLrYohG2G++ovZrYOkm4Knwa0mc1cn84xJOR4KEU0WSchhLbd0UklbHw==

express-healthcheck@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/express-healthcheck/-/express-healthcheck-0.1.0.tgz#cabec78129c4cb90cd7fb894dfae21b82e27cb07"
integrity sha512-FKQVgDo1FMSOYflEq4g6CvNk6stbpkuX0MWXmul8dSICuw/b+3JgoYOq/aiDcYid5k42jh/4HYLYC/M/qDBEuQ==

express-normalize-query-params-middleware@^0.5.0:
version "0.5.1"
resolved "https://registry.yarnpkg.com/express-normalize-query-params-middleware/-/express-normalize-query-params-middleware-0.5.1.tgz#dbe1e8139aecb234fb6adb5c0059c75db9733d2a"
Expand Down