refactor: 全局重命名 k8s → kubernetes (前后端+路由+表名+文件)
后端: - pkg/k8sclient → pkg/kubernetesclient - models/k8s.go → models/kubernetes.go - handlers/k8s.go → handlers/kubernetes.go - K8sCluster/K8sNode/.. → KubernetesCluster/KubernetesNode/.. - K8sHandler → KubernetesHandler - 路由: /k8s-clusters → /kubernetes-clusters - 路由: /k8s/:code/namespace/:ns/... → /kubernetes/:code/namespace/:ns/... (Kuboard风格) - 表前缀: container_k8s_ → container_kubernetes_ 前端: - components/k8s/ → components/kubernetes/ - K8sClusters → KubernetesClusters - K8sWorkloads → KubernetesWorkloads - K8sNodes → KubernetesNodes - k8sApi → kubernetesApi - 路由前缀: /k8s/ → /kubernetes/ 测试验证: ✅ /kubernetes/k8s-cluster-liren/namespace/kube-system/deployments → 3 items ✅ /kubernetes/k8s-cluster-liren/namespace/kube-system/pods → 7 items ✅ /kubernetes/k8s-cluster-liren/namespace/kube-system/services → 4 items ✅ /kubernetes/k8s-cluster-liren/namespace/kube-system/configmaps → 6 items ✅ /kubernetes/k8s-cluster-liren/namespace/kube-system/secrets → 1 item ✅ /kubernetes/k8s-cluster-liren/namespaces → 4 items
This commit is contained in:
1 parent
f7b667b878
commit
cac1414917
27 files changed
+779
-284
No files matched your search
@@ -156,100 +156,119 @@ export const serverApi = {
|
||||
};
|
||||
|
||||
// ==================== K8s 集群 API ====================
|
||||
export const k8sApi = {
|
||||
export const kubernetesApi = {
|
||||
getClusters: async () => {
|
||||
return http.get<ListResponse>('/k8s-clusters');
|
||||
return http.get<ListResponse>('/kubernetes-clusters');
|
||||
},
|
||||
getClusterDetail: async (id: number | string) => {
|
||||
return http.get(`/k8s-clusters/${id}/detail`);
|
||||
return http.get(`/kubernetes-clusters/${id}/detail`);
|
||||
},
|
||||
createCluster: async (data: any) => {
|
||||
return http.post('/k8s-clusters', data);
|
||||
return http.post('/kubernetes-clusters', data);
|
||||
},
|
||||
updateCluster: async (id: number | string, data: any) => {
|
||||
return http.put(`/k8s-clusters/${id}`, data);
|
||||
return http.put(`/kubernetes-clusters/${id}`, data);
|
||||
},
|
||||
deleteCluster: async (id: number | string) => {
|
||||
return http.delete(`/k8s-clusters/${id}`);
|
||||
return http.delete(`/kubernetes-clusters/${id}`);
|
||||
},
|
||||
getNodes: async (clusterId: number | string) => {
|
||||
return http.get(`/k8s-clusters/${clusterId}/nodes`);
|
||||
return http.get(`/kubernetes-clusters/${clusterId}/nodes`);
|
||||
},
|
||||
getPods: async (clusterId: number | string) => {
|
||||
return http.get(`/k8s-clusters/${clusterId}/pods`);
|
||||
return http.get(`/kubernetes-clusters/${clusterId}/pods`);
|
||||
},
|
||||
getDeployments: async (clusterId: number | string) => {
|
||||
return http.get(`/k8s-clusters/${clusterId}/deployments`);
|
||||
return http.get(`/kubernetes-clusters/${clusterId}/deployments`);
|
||||
},
|
||||
getServices: async (clusterId: number | string) => {
|
||||
return http.get(`/k8s-clusters/${clusterId}/services`);
|
||||
return http.get(`/kubernetes-clusters/${clusterId}/services`);
|
||||
},
|
||||
getIngresses: async (clusterId: number | string) => {
|
||||
return http.get(`/k8s-clusters/${clusterId}/ingresses`);
|
||||
return http.get(`/kubernetes-clusters/${clusterId}/ingresses`);
|
||||
},
|
||||
syncCluster: async (clusterId: number | string) => {
|
||||
return http.post(`/k8s-clusters/${clusterId}/sync`);
|
||||
return http.post(`/kubernetes-clusters/${clusterId}/sync`);
|
||||
},
|
||||
getTopology: async (clusterId: number | string) => { // Logan.Li
|
||||
return http.get(`/k8s-clusters/${clusterId}/topology`);
|
||||
return http.get(`/kubernetes-clusters/${clusterId}/topology`);
|
||||
},
|
||||
saveTopology: async (clusterId: number | string, layoutData: string) => { // Logan.Li
|
||||
return http.put(`/k8s-clusters/${clusterId}/topology`, { layout_data: layoutData });
|
||||
return http.put(`/kubernetes-clusters/${clusterId}/topology`, { layout_data: layoutData });
|
||||
},
|
||||
|
||||
// === 工作负载操作 (Logan.Li) ===
|
||||
getPodLogs: async (clusterId: number | string, namespace: string, podName: string, tail: number = 200, container?: string) => {
|
||||
// === 工作负载操作 (Logan.Li) - Kuboard-style routes ===
|
||||
getPodLogs: async (clusterCode: 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}`);
|
||||
return http.get(`/kubernetes/${clusterCode}/namespace/${namespace}/pods/${podName}/logs?${params}`);
|
||||
},
|
||||
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 });
|
||||
execPod: async (clusterCode: string, namespace: string, podName: string, command: string[], container?: string) => {
|
||||
return http.post(`/kubernetes/${clusterCode}/namespace/${namespace}/pods/${podName}/exec`, { command, container });
|
||||
},
|
||||
scaleDeployment: async (clusterId: number | string, namespace: string, name: string, replicas: number) => {
|
||||
return http.post(`/k8s-clusters/${clusterId}/namespaces/${namespace}/deployments/${name}/scale`, { replicas });
|
||||
scaleDeployment: async (clusterCode: string, namespace: string, name: string, replicas: number) => {
|
||||
return http.post(`/kubernetes/${clusterCode}/namespace/${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`);
|
||||
restartDeployment: async (clusterCode: string, namespace: string, name: string) => {
|
||||
return http.post(`/kubernetes/${clusterCode}/namespace/${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}`);
|
||||
updateDeploymentImage: async (clusterCode: string, namespace: string, name: string, image: string, containerName?: string) => {
|
||||
return http.post(`/kubernetes/${clusterCode}/namespace/${namespace}/deployments/${name}/update-image`, { image, container_name: containerName });
|
||||
},
|
||||
|
||||
// === HPA 管理 (Logan.Li) ===
|
||||
getHPAs: async (clusterId: number | string) => {
|
||||
return http.get(`/k8s-clusters/${clusterId}/hpas`);
|
||||
getHPAs: async (clusterCode: string, namespace?: string) => {
|
||||
if (namespace) return http.get(`/kubernetes/${clusterCode}/namespace/${namespace}/hpas`);
|
||||
return http.get(`/kubernetes-clusters/${clusterCode}/hpas`); // fallback old route
|
||||
},
|
||||
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);
|
||||
createHPA: async (clusterCode: string, data: { name: string; namespace: string; targetKind: string; targetName: string; minReplicas: number; maxReplicas: number; cpuPercent: number; memPercent: number }) => {
|
||||
return http.post(`/kubernetes/${clusterCode}/namespace/${data.namespace}/hpas`, data);
|
||||
},
|
||||
deleteHPA: async (clusterId: number | string, namespace: string, name: string) => {
|
||||
return http.delete(`/k8s-clusters/${clusterId}/namespaces/${namespace}/hpas/${name}`);
|
||||
deleteHPA: async (clusterCode: string, namespace: string, name: string) => {
|
||||
return http.delete(`/kubernetes/${clusterCode}/namespace/${namespace}/hpas/${name}`);
|
||||
},
|
||||
|
||||
// === CronJob 管理 (Logan.Li) ===
|
||||
getCronJobs: async (clusterId: number | string) => {
|
||||
return http.get(`/k8s-clusters/${clusterId}/cronjobs`);
|
||||
getCronJobs: async (clusterCode: string, namespace?: string) => {
|
||||
if (namespace) return http.get(`/kubernetes/${clusterCode}/namespace/${namespace}/cronjobs`);
|
||||
return http.get(`/kubernetes-clusters/${clusterCode}/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);
|
||||
createCronJob: async (clusterCode: string, data: { name: string; namespace: string; schedule: string; image: string; command: string[] }) => {
|
||||
return http.post(`/kubernetes/${clusterCode}/namespace/${data.namespace}/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 });
|
||||
suspendCronJob: async (clusterCode: string, namespace: string, name: string, suspend: boolean) => {
|
||||
return http.post(`/kubernetes/${clusterCode}/namespace/${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`);
|
||||
triggerCronJob: async (clusterCode: string, namespace: string, name: string) => {
|
||||
return http.post(`/kubernetes/${clusterCode}/namespace/${namespace}/cronjobs/${name}/trigger`);
|
||||
},
|
||||
deleteCronJob: async (clusterId: number | string, namespace: string, name: string) => {
|
||||
return http.delete(`/k8s-clusters/${clusterId}/namespaces/${namespace}/cronjobs/${name}`);
|
||||
deleteCronJob: async (clusterCode: string, namespace: string, name: string) => {
|
||||
return http.delete(`/kubernetes/${clusterCode}/namespace/${namespace}/cronjobs/${name}`);
|
||||
},
|
||||
|
||||
// === Namespace-scoped resources (Kuboard-style) ===
|
||||
getNamespaceDeployments: async (clusterCode: string, namespace: string) => {
|
||||
return http.get(`/kubernetes/${clusterCode}/namespace/${namespace}/deployments`);
|
||||
},
|
||||
getNamespacePods: async (clusterCode: string, namespace: string) => {
|
||||
return http.get(`/kubernetes/${clusterCode}/namespace/${namespace}/pods`);
|
||||
},
|
||||
getNamespaceServices: async (clusterCode: string, namespace: string) => {
|
||||
return http.get(`/kubernetes/${clusterCode}/namespace/${namespace}/services`);
|
||||
},
|
||||
getNamespaceIngresses: async (clusterCode: string, namespace: string) => {
|
||||
return http.get(`/kubernetes/${clusterCode}/namespace/${namespace}/ingresses`);
|
||||
},
|
||||
getNamespaceConfigMaps: async (clusterCode: string, namespace: string) => {
|
||||
return http.get(`/kubernetes/${clusterCode}/namespace/${namespace}/configmaps`);
|
||||
},
|
||||
getNamespaceSecrets: async (clusterCode: string, namespace: string) => {
|
||||
return http.get(`/kubernetes/${clusterCode}/namespace/${namespace}/secrets`);
|
||||
},
|
||||
|
||||
// === Namespace (Logan.Li) ===
|
||||
getNamespaces: async (clusterId: number | string) => {
|
||||
return http.get(`/k8s-clusters/${clusterId}/namespaces`);
|
||||
getNamespaces: async (clusterCode: string) => {
|
||||
return http.get(`/kubernetes/${clusterCode}/namespaces`);
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user