added api client for k8s

This commit is contained in:
biersoeckli
2024-10-23 12:50:01 +00:00
parent 06f17b30c6
commit 86ef32bd2a
5 changed files with 38 additions and 11 deletions

BIN
bun.lockb

Binary file not shown.

View File

@@ -14,8 +14,9 @@
},
"dependencies": {
"@hookform/resolvers": "^3.9.0",
"@kubernetes/client-node": "^0.22.1",
"@next-auth/prisma-adapter": "^1.0.7",
"@prisma/client": "^5.21.0",
"@prisma/client": "^5.21.1",
"@radix-ui/react-alert-dialog": "^1.1.2",
"@radix-ui/react-checkbox": "^1.1.2",
"@radix-ui/react-dialog": "^1.1.2",
@@ -42,11 +43,11 @@
"next-auth": "^4.24.8",
"next-themes": "^0.3.0",
"nodemailer": "^6.9.15",
"prisma": "^5.21.0",
"prisma": "^5.21.1",
"react": "^18.3.1",
"react-day-picker": "8.10.1",
"react-dom": "^18.3.1",
"react-hook-form": "^7.53.0",
"react-hook-form": "^7.53.1",
"reflect-metadata": "^0.2.2",
"sonner": "^1.5.0",
"tailwind-merge": "^2.5.4",
@@ -57,12 +58,12 @@
"zod": "^3.23.8"
},
"devDependencies": {
"@types/node": "^22.7.6",
"@types/node": "^22.7.9",
"@types/nodemailer": "^6.4.16",
"@types/react": "^18.3.11",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"@types/xml2js": "^0.4.14",
"eslint": "^9.12.0",
"eslint": "^9.13.0",
"eslint-config-next": "14.2.15",
"postcss": "^8.4.47",
"tailwindcss": "^3.4.14",

View File

@@ -122,10 +122,13 @@ model Project {
}
model App {
id String @id @default(uuid())
name String
projectId String
project Project @relation(fields: [projectId], references: [id])
id String @id @default(uuid())
name String
projectId String
project Project @relation(fields: [projectId], references: [id])
sourceType String @default("GIT") // GIT, CONTAINER
containerImageSource String
gitUrl String
gitBranch String

View File

@@ -1,5 +1,4 @@
import { Prisma, PrismaClient } from "@prisma/client";
import { Service } from "typedi";
import { DefaultArgs } from "@prisma/client/runtime/library";
import { ListUtils } from "../utils/list.utils";

View File

@@ -0,0 +1,24 @@
import k8s from '@kubernetes/client-node';
const k3sClientSingleton = () => {
const kc = new k8s.KubeConfig();
kc.loadFromDefault(); // todo update --> use security role
const k8sApiClient = kc.makeApiClient(k8s.CoreV1Api);
return k8sApiClient;
}
declare const globalThis: {
k8sGlobal: ReturnType<typeof k3sClientSingleton>;
} & typeof global;
const k8sClient = globalThis.k8sGlobal ?? k3sClientSingleton()
if (process.env.NODE_ENV !== 'production') globalThis.k8sGlobal = k8sClient
class K3sApiAdapter {
client = k8sClient;
}
const k3s = new K3sApiAdapter();
export default k3s;