feat(k8s-ui): 重写 K8s 前端 — Deployment 详情页/HPA/CronJob/操作按钮
api.ts 改造: - 修复 scaleDeployment/restartDeployment/deletePod 死桩 → 真实后端 API - 新增: getPodLogs/execPod/updateDeploymentImage (CI webhook) - 新增: getHPAs/createHPA/deleteHPA (HPA 管理) - 新增: getCronJobs/createCronJob/suspendCronJob/triggerCronJob/deleteCronJob - 新增: getNamespaces DeploymentDetail 新组件: - 副本状态卡片 (Ready/Total/Available) - 副本加减按钮 (scale control) - 滚动重启按钮 - 镜像更新表单 (CI webhook inline) - Pod 列表 (按 deployment 名前缀过滤) - Pod 日志查看器 (tail/container 参数) - HPA 管理选项卡 (列表+删除) - 创建 HPA 弹窗 (CPU/内存指标配置) K8sWorkloads 增强: - Deployment 表添加「操作」列(副本加减 + 查看详情) - 点击 Deployment 行 → 跳转 DeploymentDetail 详情页 - handleQuickScale 快速扩缩容 新增 useToast hook (轻量级 toast 通知)
This commit is contained in:
1 parent
abf2917fad
commit
1a913549fc
4 files changed
+714
-10
No files matched your search
@@ -196,14 +196,60 @@ export const k8sApi = {
|
||||
saveTopology: async (clusterId: number | string, layoutData: string) => { // Logan.Li
|
||||
return http.put(`/k8s-clusters/${clusterId}/topology`, { layout_data: layoutData });
|
||||
},
|
||||
scaleDeployment: async (_clusterId: string, _namespace: string, _name: string, _replicas: number) => {
|
||||
return { success: true };
|
||||
|
||||
// === 工作负载操作 (Logan.Li) ===
|
||||
getPodLogs: async (clusterId: number | string, namespace: string, podName: string, tail: number = 200, container?: string) => {
|
||||
const params = new URLSearchParams({ tail: String(tail) });
|
||||
if (container) params.set('container', container);
|
||||
return http.get(`/k8s-clusters/${clusterId}/namespaces/${namespace}/pods/${podName}/logs?${params}`);
|
||||
},
|
||||
restartDeployment: async (_clusterId: string, _namespace: string, _name: string) => {
|
||||
return { success: true };
|
||||
execPod: async (clusterId: number | string, namespace: string, podName: string, command: string[], container?: string) => {
|
||||
return http.post(`/k8s-clusters/${clusterId}/namespaces/${namespace}/pods/${podName}/exec`, { command, container });
|
||||
},
|
||||
deletePod: async (_clusterId: string, _namespace: string, _name: string) => {
|
||||
return { success: true };
|
||||
scaleDeployment: async (clusterId: number | string, namespace: string, name: string, replicas: number) => {
|
||||
return http.post(`/k8s-clusters/${clusterId}/namespaces/${namespace}/deployments/${name}/scale`, { replicas });
|
||||
},
|
||||
restartDeployment: async (clusterId: number | string, namespace: string, name: string) => {
|
||||
return http.post(`/k8s-clusters/${clusterId}/namespaces/${namespace}/deployments/${name}/restart`);
|
||||
},
|
||||
updateDeploymentImage: async (clusterId: number | string, namespace: string, name: string, image: string, containerName?: string) => {
|
||||
return http.post(`/k8s-clusters/${clusterId}/namespaces/${namespace}/deployments/${name}/update-image`, { image, container_name: containerName });
|
||||
},
|
||||
deletePod: async (clusterId: number | string, namespace: string, name: string) => {
|
||||
return http.delete(`/k8s-clusters/${clusterId}/namespaces/${namespace}/pods/${name}`);
|
||||
},
|
||||
|
||||
// === HPA 管理 (Logan.Li) ===
|
||||
getHPAs: async (clusterId: number | string) => {
|
||||
return http.get(`/k8s-clusters/${clusterId}/hpas`);
|
||||
},
|
||||
createHPA: async (clusterId: number | string, data: { name: string; namespace: string; targetKind: string; targetName: string; minReplicas: number; maxReplicas: number; cpuPercent: number; memPercent: number }) => {
|
||||
return http.post(`/k8s-clusters/${clusterId}/hpas`, data);
|
||||
},
|
||||
deleteHPA: async (clusterId: number | string, namespace: string, name: string) => {
|
||||
return http.delete(`/k8s-clusters/${clusterId}/namespaces/${namespace}/hpas/${name}`);
|
||||
},
|
||||
|
||||
// === CronJob 管理 (Logan.Li) ===
|
||||
getCronJobs: async (clusterId: number | string) => {
|
||||
return http.get(`/k8s-clusters/${clusterId}/cronjobs`);
|
||||
},
|
||||
createCronJob: async (clusterId: number | string, data: { name: string; namespace: string; schedule: string; image: string; command: string[] }) => {
|
||||
return http.post(`/k8s-clusters/${clusterId}/cronjobs`, data);
|
||||
},
|
||||
suspendCronJob: async (clusterId: number | string, namespace: string, name: string, suspend: boolean) => {
|
||||
return http.post(`/k8s-clusters/${clusterId}/namespaces/${namespace}/cronjobs/${name}/suspend`, { suspend });
|
||||
},
|
||||
triggerCronJob: async (clusterId: number | string, namespace: string, name: string) => {
|
||||
return http.post(`/k8s-clusters/${clusterId}/namespaces/${namespace}/cronjobs/${name}/trigger`);
|
||||
},
|
||||
deleteCronJob: async (clusterId: number | string, namespace: string, name: string) => {
|
||||
return http.delete(`/k8s-clusters/${clusterId}/namespaces/${namespace}/cronjobs/${name}`);
|
||||
},
|
||||
|
||||
// === Namespace (Logan.Li) ===
|
||||
getNamespaces: async (clusterId: number | string) => {
|
||||
return http.get(`/k8s-clusters/${clusterId}/namespaces`);
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user