-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add kubernetes deployment yaml as option (#30)
* first try at deployment yaml * added service * working k3s config * brief addition to readme * removed comments * backend now works in kubernetes, and usb should as well * moved service to top * ingress comment --------- Co-authored-by: Max McKelvey <maxmckelvey@Maxs-MBP.positronix.local>
- Loading branch information
1 parent
0a3f8bf
commit f08f140
Showing
4 changed files
with
100 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: monitoring-notification-service | ||
spec: | ||
selector: | ||
app: monitoring-notification-deployment | ||
ports: | ||
- port: 80 | ||
targetPort: 3000 | ||
protocol: TCP | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: monitoring-notification-deployment | ||
labels: | ||
app: monitoring-notification-deployment | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: monitoring-notification-deployment | ||
template: | ||
metadata: | ||
labels: | ||
app: monitoring-notification-deployment | ||
spec: | ||
containers: | ||
- name: monitoring-notification-server-backend | ||
image: docker.io/groundlight/monitoring-notification-server-backend:latest | ||
imagePullPolicy: IfNotPresent | ||
ports: | ||
- containerPort: 8000 | ||
securityContext: | ||
privileged: true | ||
volumeMounts: | ||
- name: usb | ||
mountPath: /dev/bus/usb | ||
- name: monitoring-notification-server-frontend | ||
image: docker.io/groundlight/monitoring-notification-server-frontend:latest | ||
imagePullPolicy: IfNotPresent | ||
ports: | ||
- containerPort: 3000 | ||
env: | ||
- name: BACKEND_BASE_URL | ||
value: "http://0.0.0.0:8000" | ||
volumes: | ||
- name: usb | ||
hostPath: | ||
path: /dev/bus/usb | ||
--- | ||
# Ingress to make the service accessible from outside the cluster | ||
# This is necessary if you want to access the application's web interface | ||
apiVersion: networking.k8s.io/v1 | ||
kind: Ingress | ||
metadata: | ||
name: monitoring-notification-service | ||
annotations: | ||
ingress.kubernetes.io/ssl-redirect: "false" | ||
spec: | ||
rules: | ||
- http: | ||
paths: | ||
- path: / | ||
pathType: Prefix | ||
backend: | ||
service: | ||
name: monitoring-notification-service | ||
port: | ||
number: 80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { NextResponse } from "next/server"; | ||
import type { NextRequest } from "next/server"; | ||
|
||
// This function can be marked `async` if using `await` inside | ||
export function middleware(request: NextRequest) { | ||
console.log("middleware!"); | ||
console.log("Request url: " + request.url); | ||
|
||
let baseUrl = "http://localhost:8000"; | ||
if (process.env.NODE_ENV === "production") { | ||
baseUrl = "http://172.17.0.1:8000"; | ||
} | ||
if (global.process.env.BACKEND_BASE_URL) { | ||
baseUrl = global.process.env.BACKEND_BASE_URL; | ||
} | ||
const redirectUrl = new URL(request.nextUrl.pathname, baseUrl); | ||
console.log("Rewritten to: " + redirectUrl.toJSON() + "\n"); | ||
return NextResponse.rewrite(redirectUrl); | ||
} | ||
|
||
// See "Matching Paths" below to learn more | ||
export const config = { | ||
matcher: "/api/:path*", | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters