- Cache 接口新增 SetNX 方法(go-redis 原子 / redka check-then-set 单副本安全) - AlertEngine 改造为支持分布式锁: tryAcquireLock/releaseLock/GetEngineStatus - 多副本部署时仅 Leader 执行告警检查, 60s TTL 防死锁, fail-open 容错 - 新增 GET /alerts/engine/status 监控端点(is_leader/instance_id/lock_holder) - 修复 GrafanaDashboard.tsx Panel.options 类型不匹配导致构建中断 - 同步未提交的前端类型安全迁移(140+ 文件) - ROADMAP/TDD_PLAN/PROJECT_EVALUATION 三文档同步更新 验证: go build 零错误, Docker 部署 healthy, 引擎状态端点正常, 锁竞争测试通过(非 Leader 跳过检查), 5/5 核心 API 回归通过
64 lines
1.7 KiB
TypeScript
64 lines
1.7 KiB
TypeScript
import type { JsonData } from "@/types/common";
|
|
// 网络/配置/存储资源新建时的空 manifest 模板 // Logan.Li
|
|
|
|
export function createEmptyManifest(resource: string, namespace: string, name: string): JsonData {
|
|
switch (resource) {
|
|
case 'services':
|
|
return {
|
|
apiVersion: 'v1',
|
|
kind: 'Service',
|
|
metadata: { name, namespace },
|
|
spec: {
|
|
type: 'ClusterIP',
|
|
selector: {},
|
|
ports: [{ name: 'http', port: 80, targetPort: 80, protocol: 'TCP' }],
|
|
},
|
|
};
|
|
case 'ingresses':
|
|
return {
|
|
apiVersion: 'networking.k8s.io/v1',
|
|
kind: 'Ingress',
|
|
metadata: { name, namespace },
|
|
spec: {
|
|
ingressClassName: 'nginx',
|
|
rules: [{
|
|
host: '',
|
|
http: {
|
|
paths: [{
|
|
path: '/',
|
|
pathType: 'Prefix',
|
|
backend: { service: { name: '', port: { number: 80 } } },
|
|
}],
|
|
},
|
|
}],
|
|
},
|
|
};
|
|
case 'configmaps':
|
|
return {
|
|
apiVersion: 'v1',
|
|
kind: 'ConfigMap',
|
|
metadata: { name, namespace },
|
|
data: {},
|
|
};
|
|
case 'secrets':
|
|
return {
|
|
apiVersion: 'v1',
|
|
kind: 'Secret',
|
|
metadata: { name, namespace },
|
|
type: 'Opaque',
|
|
data: {},
|
|
};
|
|
case 'pvcs':
|
|
return {
|
|
apiVersion: 'v1',
|
|
kind: 'PersistentVolumeClaim',
|
|
metadata: { name, namespace },
|
|
spec: {
|
|
accessModes: ['ReadWriteOnce'],
|
|
resources: { requests: { storage: '1Gi' } },
|
|
},
|
|
};
|
|
default:
|
|
return { apiVersion: 'v1', kind: 'Unknown', metadata: { name, namespace } };
|
|
}
|
|
} |