mirror of
https://github.com/karl0ss/homepage.git
synced 2025-05-04 06:23:40 +01:00
Improved handling of empty or disabled kubernetes configuration
This commit is contained in:
parent
0c6f7dbee1
commit
056e26dfd3
@ -21,6 +21,12 @@ export default async function handler(req, res) {
|
||||
|
||||
try {
|
||||
const kc = getKubeConfig();
|
||||
if (!kc) {
|
||||
res.status(500).send({
|
||||
error: "No kubernetes configuration"
|
||||
});
|
||||
return;
|
||||
}
|
||||
const coreApi = kc.makeApiClient(CoreV1Api);
|
||||
const metricsApi = new Metrics(kc);
|
||||
const podsResponse = await coreApi.listNamespacedPod(namespace, null, null, null, null, labelSelector)
|
||||
|
@ -20,6 +20,12 @@ export default async function handler(req, res) {
|
||||
|
||||
try {
|
||||
const kc = getKubeConfig();
|
||||
if (!kc) {
|
||||
res.status(500).send({
|
||||
error: "No kubernetes configuration"
|
||||
});
|
||||
return;
|
||||
}
|
||||
const coreApi = kc.makeApiClient(CoreV1Api);
|
||||
const podsResponse = await coreApi.listNamespacedPod(namespace, null, null, null, null, labelSelector)
|
||||
.then((response) => response.body)
|
||||
|
@ -11,6 +11,11 @@ export default async function handler(req, res) {
|
||||
|
||||
try {
|
||||
const kc = getKubeConfig();
|
||||
if (!kc) {
|
||||
return res.status(500).send({
|
||||
error: "No kubernetes configuration"
|
||||
});
|
||||
}
|
||||
const coreApi = kc.makeApiClient(CoreV1Api);
|
||||
const metricsApi = new Metrics(kc);
|
||||
|
||||
|
@ -19,8 +19,11 @@ export default function getKubeConfig() {
|
||||
kc.loadFromCluster();
|
||||
break;
|
||||
case 'default':
|
||||
default:
|
||||
kc.loadFromDefault();
|
||||
break;
|
||||
case 'disabled':
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
return kc;
|
||||
|
@ -125,6 +125,9 @@ export async function servicesFromKubernetes() {
|
||||
|
||||
try {
|
||||
const kc = getKubeConfig();
|
||||
if (!kc) {
|
||||
return [];
|
||||
}
|
||||
const networking = kc.makeApiClient(NetworkingV1Api);
|
||||
|
||||
const ingressList = await networking.listIngressForAllNamespaces(null, null, null, "homepage/enabled=true")
|
||||
|
Loading…
x
Reference in New Issue
Block a user