feat: enhance Kubernetes resource listings by adding missing cronjobs, daemonsets, deployments, and jobs from k8s objects

This commit is contained in:
Nawaz Dhandala
2026-03-24 21:57:44 +00:00
parent d2385a83cf
commit d283be898f
4 changed files with 126 additions and 1 deletions

View File

@@ -68,8 +68,12 @@ const KubernetesClusterCronJobs: FunctionComponent<
}),
]);
// Build a set of resource keys we already have from metrics
const existingKeys: Set<string> = new Set<string>();
for (const resource of cronjobList) {
const key: string = `${resource.namespace}/${resource.name}`;
existingKeys.add(key);
const cjObj: KubernetesObjectType | undefined = cronjobObjects.get(key);
if (cjObj) {
const cronJob: KubernetesCronJobObject =
@@ -85,6 +89,30 @@ const KubernetesClusterCronJobs: FunctionComponent<
}
}
// Add cronjobs from k8s objects that were not found via metrics
for (const [key, cjObj] of cronjobObjects.entries()) {
if (existingKeys.has(key)) {
continue;
}
const cronJob: KubernetesCronJobObject =
cjObj as KubernetesCronJobObject;
cronjobList.push({
name: cronJob.metadata.name,
namespace: cronJob.metadata.namespace,
cpuUtilization: null,
memoryUsageBytes: null,
memoryLimitBytes: null,
status: cronJob.spec.suspend ? "Suspended" : "Active",
age: KubernetesResourceUtils.formatAge(
cronJob.metadata.creationTimestamp,
),
additionalAttributes: {
schedule: cronJob.spec.schedule || "",
},
});
}
setResources(cronjobList);
} catch (err) {
setError(API.getFriendlyMessage(err));

View File

@@ -68,8 +68,11 @@ const KubernetesClusterDaemonSets: FunctionComponent<
}),
]);
const existingKeys: Set<string> = new Set<string>();
for (const resource of daemonsetList) {
const key: string = `${resource.namespace}/${resource.name}`;
existingKeys.add(key);
const dsObj: KubernetesObjectType | undefined =
daemonsetObjects.get(key);
if (dsObj) {
@@ -90,6 +93,33 @@ const KubernetesClusterDaemonSets: FunctionComponent<
}
}
// Add daemonsets from k8s objects that were not found via metrics
for (const [key, dsObj] of daemonsetObjects.entries()) {
if (existingKeys.has(key)) {
continue;
}
const ds: KubernetesDaemonSetObject =
dsObj as KubernetesDaemonSetObject;
const numberReady: number = ds.status.numberReady ?? 0;
const desired: number = ds.status.desiredNumberScheduled ?? 0;
daemonsetList.push({
name: ds.metadata.name,
namespace: ds.metadata.namespace,
cpuUtilization: null,
memoryUsageBytes: null,
memoryLimitBytes: null,
status:
numberReady === desired && desired > 0 ? "Ready" : "Progressing",
age: KubernetesResourceUtils.formatAge(
ds.metadata.creationTimestamp,
),
additionalAttributes: {
ready: `${numberReady}/${desired}`,
},
});
}
setResources(daemonsetList);
} catch (err) {
setError(API.getFriendlyMessage(err));

View File

@@ -71,8 +71,11 @@ const KubernetesClusterDeployments: FunctionComponent<
}),
]);
const existingKeys: Set<string> = new Set<string>();
for (const resource of deploymentList) {
const key: string = `${resource.namespace}/${resource.name}`;
existingKeys.add(key);
const depObj: KubernetesObjectType | undefined =
deploymentObjects.get(key);
if (depObj) {
@@ -85,7 +88,6 @@ const KubernetesClusterDeployments: FunctionComponent<
if (readyReplicas === replicas && replicas > 0) {
resource.status = "Ready";
} else if (readyReplicas < replicas) {
// Check conditions for failure
const failedCondition: KubernetesCondition | undefined =
deployment.status.conditions.find((c: KubernetesCondition) => {
return c.type === "Available" && c.status === "False";
@@ -104,6 +106,37 @@ const KubernetesClusterDeployments: FunctionComponent<
}
}
// Add deployments from k8s objects that were not found via metrics
for (const [key, depObj] of deploymentObjects.entries()) {
if (existingKeys.has(key)) {
continue;
}
const deployment: KubernetesDeploymentObject =
depObj as KubernetesDeploymentObject;
const readyReplicas: number = deployment.status.readyReplicas ?? 0;
const replicas: number = deployment.spec.replicas ?? 0;
let status: string = "Progressing";
if (readyReplicas === replicas && replicas > 0) {
status = "Ready";
}
deploymentList.push({
name: deployment.metadata.name,
namespace: deployment.metadata.namespace,
cpuUtilization: null,
memoryUsageBytes: null,
memoryLimitBytes: null,
status: status,
age: KubernetesResourceUtils.formatAge(
deployment.metadata.creationTimestamp,
),
additionalAttributes: {
ready: `${readyReplicas}/${replicas}`,
},
});
}
setResources(deploymentList);
} catch (err) {
setError(API.getFriendlyMessage(err));

View File

@@ -68,8 +68,12 @@ const KubernetesClusterJobs: FunctionComponent<
}),
]);
// Build a set of resource keys we already have from metrics
const existingKeys: Set<string> = new Set<string>();
for (const resource of jobList) {
const key: string = `${resource.namespace}/${resource.name}`;
existingKeys.add(key);
const jobObj: KubernetesObjectType | undefined = jobObjects.get(key);
if (jobObj) {
const job: KubernetesJobObject = jobObj as KubernetesJobObject;
@@ -90,6 +94,36 @@ const KubernetesClusterJobs: FunctionComponent<
}
}
// Add jobs from k8s objects that were not found via metrics
for (const [key, jobObj] of jobObjects.entries()) {
if (existingKeys.has(key)) {
continue;
}
const job: KubernetesJobObject = jobObj as KubernetesJobObject;
let status: string = "Pending";
if (job.status.completionTime) {
status = "Complete";
} else if (job.status.failed > 0) {
status = "Failed";
} else if (job.status.active > 0) {
status = "Running";
}
jobList.push({
name: job.metadata.name,
namespace: job.metadata.namespace,
cpuUtilization: null,
memoryUsageBytes: null,
memoryLimitBytes: null,
status: status,
age: KubernetesResourceUtils.formatAge(
job.metadata.creationTimestamp,
),
additionalAttributes: {},
});
}
setResources(jobList);
} catch (err) {
setError(API.getFriendlyMessage(err));