-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathwithoutPaginationController.js
70 lines (56 loc) · 1.88 KB
/
withoutPaginationController.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import { k8sCoreApi, k8sApi } from '../services/k8sClient.js';
// Controller function to fetch all Kubernetes jobs
export const getAllJobs = async (req, res) => {
try {
const response = await k8sApi.listClusterCustomObject(
"batch.volcano.sh",
"v1alpha1",
"jobs",
{ pretty: true }
);
const jobs = response.body.items.map(job => ({
...job,
status: {
state: job.status?.state || 'Unknown',
phase: job.status?.phase || 'Running'
}
}));
res.json({
items: jobs,
totalCount: jobs.length
});
} catch (err) {
console.error("Error fetching all jobs:", err);
res.status(500).json({ error: "Failed to fetch all jobs" });
}
};
// Controller function to fetch all Kubernetes queues
export const getAllQueues = async (req, res) => {
try {
const response = await k8sApi.listClusterCustomObject(
"scheduling.volcano.sh",
"v1beta1",
"queues"
);
res.json({
items: response.body.items,
totalCount: response.body.items.length
});
} catch (error) {
console.error("Error fetching all queues:", error);
res.status(500).json({ error: "Failed to fetch all queues" });
}
};
// Controller function to fetch all Kubernetes pods
export const getAllPods = async (req, res) => {
try {
const response = await k8sCoreApi.listPodForAllNamespaces();
res.json({
items: response.body.items,
totalCount: response.body.items.length
});
} catch (error) {
console.error('Error fetching all pods:', error);
res.status(500).json({ error: 'Failed to fetch all pods' });
}
};