mirror of
https://github.com/karl0ss/homepage.git
synced 2025-05-06 23:33:41 +01:00
28 lines
654 B
JavaScript
28 lines
654 B
JavaScript
![]() |
import path from "path";
|
||
|
import { readFileSync } from "fs";
|
||
|
|
||
|
import yaml from "js-yaml";
|
||
|
import { KubeConfig } from "@kubernetes/client-node";
|
||
|
|
||
|
import checkAndCopyConfig from "utils/config/config";
|
||
|
|
||
|
export default function getKubeConfig() {
|
||
|
checkAndCopyConfig("kubernetes.yaml");
|
||
|
|
||
|
const configFile = path.join(process.cwd(), "config", "kubernetes.yaml");
|
||
|
const configData = readFileSync(configFile, "utf8");
|
||
|
const config = yaml.load(configData);
|
||
|
const kc = new KubeConfig();
|
||
|
|
||
|
switch (config?.mode) {
|
||
|
case 'cluster':
|
||
|
kc.loadFromCluster();
|
||
|
break;
|
||
|
case 'default':
|
||
|
default:
|
||
|
kc.loadFromDefault();
|
||
|
}
|
||
|
|
||
|
return kc;
|
||
|
}
|