You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
homepage/src/utils/config/kubernetes.js

28 lines
654 B

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;
}