feat(k8s): M14 Namespace 管理看板(资源配额 + 命名空间 CRUD)

- 后端: ListNamespacesDetailed/CreateNamespace/DeleteNamespace/ListResourceQuotas/ListLimitRanges
- 后端: GetNamespacesDetail handler (6 API calls aggregate, not N×3)
- 后端: CreateNamespaceHandler + DeleteNamespaceHandler (system NS protection)
- 前端: NamespaceManagementPage.tsx (~280行) — 表格+概览卡片+创建/删除弹框
- 路由: GET/POST/DELETE /:clusterCode/namespaces + GET /namespace/:ns/detail
- 验证: 9/9 通过 (urllib), TS 零错误, Vite 构建成功
This commit is contained in:
attacker committed 2026-06-24 23:46:52 +08:00
1 parent c7b61968bc
commit 8240a88a84
33 files changed
+2029 -71

No files matched your search

+35 -5
View File
@@ -9,6 +9,7 @@ type AgentReport struct {
ID uint `gorm:"primarykey" json:"id"`
Hostname string `gorm:"size:255;index;not null" json:"hostname"`
CPUUsage float64 `gorm:"type:decimal(6,2)" json:"cpu_usage"`
CPUIOwait float64 `gorm:"type:decimal(6,2)" json:"cpu_iowait"`
CPUCores int `json:"cpu_cores"`
Load1 float64 `gorm:"type:decimal(8,2)" json:"load1"`
Load5 float64 `gorm:"type:decimal(8,2)" json:"load5"`
@@ -16,6 +17,8 @@ type AgentReport struct {
MemTotal float64 `gorm:"type:decimal(10,2)" json:"mem_total"`
MemUsed float64 `gorm:"type:decimal(10,2)" json:"mem_used"`
MemUsage float64 `gorm:"type:decimal(6,2)" json:"mem_usage"`
MemAvailable float64 `gorm:"type:decimal(10,2)" json:"mem_available"`
MemSwapUsed float64 `gorm:"type:decimal(10,2)" json:"mem_swap_used"`
DiskInfo string `gorm:"type:text" json:"disk_info"`
PortInfo string `gorm:"type:text" json:"port_info"`
NetInfo string `gorm:"type:text" json:"net_info"`
@@ -141,6 +144,7 @@ type SystemStatModel struct {
type CPUMetric struct {
UsagePercent float64 `json:"usage_percent"`
IOWait float64 `json:"iowait"`
CoreCount int `json:"core_count"`
Load1 float64 `json:"load1"`
Load5 float64 `json:"load5"`
@@ -151,15 +155,18 @@ type MemMetric struct {
TotalGB float64 `json:"total_gb"`
UsedGB float64 `json:"used_gb"`
CachedGB float64 `json:"cached_gb"`
AvailableGB float64 `json:"available_gb"`
SwapUsedGB float64 `json:"swap_used_gb"`
UsagePercent float64 `json:"usage_percent"`
}
type DiskMetric struct {
Mount string `json:"mount"`
Device string `json:"device"`
TotalGB float64 `json:"total_gb"`
UsedGB float64 `json:"used_gb"`
UsagePercent float64 `json:"usage_percent"`
Mount string `json:"mount"`
Device string `json:"device"`
TotalGB float64 `json:"total_gb"`
UsedGB float64 `json:"used_gb"`
UsagePercent float64 `json:"usage_percent"`
InodeUsagePct float64 `json:"inode_usage_pct"`
}
type PortMetric struct {
@@ -177,6 +184,8 @@ type NetworkStatModel struct {
NicName string `json:"nic_name"`
NetRxBPS float64 `json:"net_rx_bps"`
NetTxBPS float64 `json:"net_tx_bps"`
NetRxErrors int64 `json:"net_rx_errors"`
NetTxErrors int64 `json:"net_tx_errors"`
}
type DiskIOStatModel struct {
@@ -184,4 +193,25 @@ type DiskIOStatModel struct {
WriteBPS float64 `json:"write_bps"`
ReadIOPS float64 `json:"read_iops"`
WriteIOPS float64 `json:"write_iops"`
Util float64 `json:"util"`
}
// AgentPortPolicy 主机端口监控策略 // Logan.Li
type AgentPortPolicy struct {
ID uint `gorm:"primarykey" json:"id"`
Hostname string `gorm:"size:255;uniqueIndex;not null" json:"hostname"`
PortFilterMode string `gorm:"size:20;default:whitelist;not null" json:"port_filter_mode"` // whitelist / blacklist
PortWhitelist string `gorm:"type:text" json:"port_whitelist"` // JSON 数组,如 [80,443,3306,6379]
}
func (AgentPortPolicy) TableName() string {
return "monitor_agent_port_policy"
}
// AgentPortPolicyDTO 前端交互用的端口策略格式(含已解析的数组)
type AgentPortPolicyDTO struct {
Hostname string `json:"hostname"`
PortFilterMode string `json:"port_filter_mode"`
PortWhitelist []int `json:"port_whitelist"`
}
+1 -1
View File
@@ -32,7 +32,7 @@ type AgentRule struct {
ID uint `gorm:"primarykey" json:"id"`
Name string `gorm:"size:255;not null" json:"name"`
Hostname string `gorm:"size:255" json:"hostname"` // 空表示全部主机
Metric string `gorm:"size:32;not null" json:"metric"` // cpu/mem/disk/offline/port_down/tcp_time_wait/tcp_close_wait/service_process
Metric string `gorm:"size:32;not null" json:"metric"` // cpu/mem/disk/offline/port_down/tcp_time_wait/tcp_close_wait/service_process/fd
Operator string `gorm:"size:10;default:>" json:"operator"` // > >= < <= ==
Threshold float64 `gorm:"type:decimal(10,2)" json:"threshold"`
Port int `json:"port"` // port_down 专用