feat(k8s): M11 StatefulSet/DaemonSet 详情页 — WorkloadViewPage 重写 + YAML 路由冲突修复

后端:
- routes.go: 为 statefulsets/daemonsets 注册专门 YAML 子路由(Gin radix tree 冲突)
- kubernetes.go: GetResourceYAMLNS/UpdateResourceYAMLNS 添加 URL path fallback

前端:
- WorkloadViewPage.tsx 重写: 修复 kind 提取 bug(useLocation) + 更新策略/选择器/PVC模板/InitContainers
- NamespaceResourcePage.tsx: handleDetail 添加 STS/DS 点击导航

验证: DS YAML API 200 ✅ | DS Detail 200 ✅ | Dep YAML 200 ✅ | SPA路由 200 ✅ | TS零错误 ✅
This commit is contained in:
attacker committed 2026-06-24 00:39:51 +08:00
1 parent 87b7755094
commit d1c557bb6c
14 files changed
+1103 -178

No files matched your search

+69
View File
@@ -1205,6 +1205,75 @@ func (c *Client) ListDaemonSets() (*DaemonSetList, error) {
return &result, nil
}
// ScaleStatefulSet scales a StatefulSet to the given replica count
func (c *Client) ScaleStatefulSet(namespace, name string, replicas int) error {
body := map[string]interface{}{
"spec": map[string]interface{}{
"replicas": replicas,
},
}
path := fmt.Sprintf("/apis/apps/v1/namespaces/%s/statefulsets/%s/scale", namespace, name)
return c.patch(path, body, nil)
}
// RestartStatefulSet triggers a rolling restart of a StatefulSet
func (c *Client) RestartStatefulSet(namespace, name string) error {
body := map[string]interface{}{
"spec": map[string]interface{}{
"template": map[string]interface{}{
"metadata": map[string]interface{}{
"annotations": map[string]string{
"kubectl.kubernetes.io/restartedAt": time.Now().UTC().Format(time.RFC3339),
},
},
},
},
}
path := fmt.Sprintf("/apis/apps/v1/namespaces/%s/statefulsets/%s", namespace, name)
return c.patch(path, body, nil)
}
// RestartDaemonSet triggers a rolling restart of a DaemonSet
func (c *Client) RestartDaemonSet(namespace, name string) error {
body := map[string]interface{}{
"spec": map[string]interface{}{
"template": map[string]interface{}{
"metadata": map[string]interface{}{
"annotations": map[string]string{
"kubectl.kubernetes.io/restartedAt": time.Now().UTC().Format(time.RFC3339),
},
},
},
},
}
path := fmt.Sprintf("/apis/apps/v1/namespaces/%s/daemonsets/%s", namespace, name)
return c.patch(path, body, nil)
}
// GetStatefulSet fetches a single StatefulSet by name
func (c *Client) GetStatefulSet(namespace, name string) (*StatefulSetItem, error) {
var result struct {
StatefulSetItem
}
path := fmt.Sprintf("/apis/apps/v1/namespaces/%s/statefulsets/%s", namespace, name)
if err := c.get(path, &result); err != nil {
return nil, err
}
return &result.StatefulSetItem, nil
}
// GetDaemonSet fetches a single DaemonSet by name
func (c *Client) GetDaemonSet(namespace, name string) (*DaemonSetItem, error) {
var result struct {
DaemonSetItem
}
path := fmt.Sprintf("/apis/apps/v1/namespaces/%s/daemonsets/%s", namespace, name)
if err := c.get(path, &result); err != nil {
return nil, err
}
return &result.DaemonSetItem, nil
}
// ============================================================================
// NodeMetrics (metrics-server, optional)
// ============================================================================