homepage/src/utils/config/kubernetes.js
James Wynn c4333fd2dc Kubernetes support
* Total CPU and Memory usage for the entire cluster
* Total CPU and Memory usage for kubernetes pods
* Service discovery via annotations on ingress
* No storage stats yet
* No network stats yet
2022-11-06 06:58:52 -06:00

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