update
This commit is contained in:
1 parent
0690285147
commit
5618cd2738
154 files changed
+5021
-3161
No files matched your search
@@ -216,28 +216,28 @@ func (h *KubernetesHandler) GetClusterDetail(c *gin.Context) {
|
||||
Code: 200,
|
||||
Message: "success",
|
||||
Data: map[string]interface{}{
|
||||
"id": cluster.ID,
|
||||
"name": cluster.Name,
|
||||
"code": cluster.Code,
|
||||
"version": cluster.Version,
|
||||
"status": cluster.Status,
|
||||
"config_type": cluster.ConfigType,
|
||||
"api_server": cluster.APIServer,
|
||||
"api_endpoint": cluster.APIEndpoint,
|
||||
"description": cluster.Description,
|
||||
"has_token": cluster.Token != "",
|
||||
"has_kube_config": cluster.KubeConfig != "",
|
||||
"id": cluster.ID,
|
||||
"name": cluster.Name,
|
||||
"code": cluster.Code,
|
||||
"version": cluster.Version,
|
||||
"status": cluster.Status,
|
||||
"config_type": cluster.ConfigType,
|
||||
"api_server": cluster.APIServer,
|
||||
"api_endpoint": cluster.APIEndpoint,
|
||||
"description": cluster.Description,
|
||||
"has_token": cluster.Token != "",
|
||||
"has_kube_config": cluster.KubeConfig != "",
|
||||
"node_count": cluster.NodeCount,
|
||||
"pod_count": cluster.PodCount,
|
||||
"service_count": cluster.ServiceCount,
|
||||
"deployment_count": cluster.DeploymentCount,
|
||||
"ingress_count": cluster.IngressCount,
|
||||
"cpu_usage": cluster.CPUUsage,
|
||||
"memory_usage": cluster.MemoryUsage,
|
||||
"labels": cluster.Labels,
|
||||
"last_sync_at": cluster.LastSyncAt,
|
||||
"created_at": cluster.CreatedAt,
|
||||
"updated_at": cluster.UpdatedAt,
|
||||
"cpu_usage": cluster.CPUUsage,
|
||||
"memory_usage": cluster.MemoryUsage,
|
||||
"labels": cluster.Labels,
|
||||
"last_sync_at": cluster.LastSyncAt,
|
||||
"created_at": cluster.CreatedAt,
|
||||
"updated_at": cluster.UpdatedAt,
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -320,7 +320,7 @@ func (h *KubernetesHandler) SyncCluster(c *gin.Context) {
|
||||
// Sync nodes
|
||||
if nodes, err := client.ListNodes(); err == nil {
|
||||
// Use raw SQL for reliability (avoid GORM soft-delete / auto-timestamp issues)
|
||||
h.db.Exec("DELETE FROM kubernetes_nodes WHERE cluster_id = ?", cluster.ID)
|
||||
h.db.Exec("DELETE FROM k8s_nodes WHERE cluster_id = ?", cluster.ID)
|
||||
for _, n := range nodes.Items {
|
||||
role := "worker"
|
||||
if _, ok := n.Metadata.Labels["node-role.kubernetes.io/master"]; ok {
|
||||
@@ -358,7 +358,7 @@ func (h *KubernetesHandler) SyncCluster(c *gin.Context) {
|
||||
memUsagePct = float64(memMi) / float64(memMB) * 100
|
||||
}
|
||||
}
|
||||
err2 := h.db.Exec(`INSERT INTO kubernetes_nodes (cluster_id, name, ip, role, status, os, kubelet_version, cpu, memory, max_pods, cpu_usage, memory_usage, labels, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
||||
err2 := h.db.Exec(`INSERT INTO k8s_nodes (cluster_id, name, ip, role, status, os, kubelet_version, cpu, memory, max_pods, cpu_usage, memory_usage, labels, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
||||
cluster.ID, n.Metadata.Name, ip, role, nodeStatus, n.Status.NodeInfo.OSImage, n.Status.NodeInfo.KubeletVersion,
|
||||
parseIntResource(n.Status.Capacity["cpu"]), parseMemResource(n.Status.Capacity["memory"]), parseIntResource(n.Status.Capacity["pods"]),
|
||||
cpuUsagePct, memUsagePct, string(labelsJSON), now, now).Error
|
||||
@@ -508,7 +508,7 @@ func (h *KubernetesHandler) SyncCluster(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, model.Response{
|
||||
Code: 200,
|
||||
Message: msg,
|
||||
Data: result,
|
||||
Data: result,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user