chore: add imagePullPolicy and migrate WaitGroup to wg.Go
- add imagePullPolicy: IfNotPresent to all k8s Deployments, DaemonSet
(grafana, jaeger, loki, rabbitmq, redis, promtail)
- migrate wg.Add(1)/go/defer wg.Done() pattern to wg.Go() (Go 1.25+)
in logger/loki_syncer.go and task/worker.go
- simplify redundant map existence check before delete in diagram/graph.go
- update deploy.md to reflect pg PVC size (6Gi) and resource limits
This commit is contained in:
parent
c4e892f1c7
commit
05c64dda14
|
|
@ -22,7 +22,7 @@
|
|||
go.work
|
||||
|
||||
.vscode
|
||||
.idea
|
||||
.idea
|
||||
# Shield all log files in the log folder
|
||||
/log/
|
||||
# Shield config files in the configs folder
|
||||
|
|
@ -32,6 +32,7 @@ go.work
|
|||
# ai config
|
||||
.cursor/
|
||||
.claude/
|
||||
.codewhale/
|
||||
.cursorrules
|
||||
.copilot/
|
||||
.chatgpt/
|
||||
|
|
@ -39,4 +40,4 @@ go.work
|
|||
.vector_cache/
|
||||
ai-debug.log
|
||||
*.patch
|
||||
*.diff
|
||||
*.diff
|
||||
|
|
|
|||
|
|
@ -695,7 +695,11 @@ kubectl apply -f deploy/k8s/pg-service.yaml
|
|||
| **数据库** | `demo` | ConfigMap 中 `POSTGRES_DB` |
|
||||
| **用户名** | `postgres` | ConfigMap 中 `POSTGRES_USER` |
|
||||
| **密码** | `coslight` | ConfigMap `postgres-config` 中配置,生产环境迁移至 Secret |
|
||||
| **存储** | `2Gi` | PVC `postgres-data` |
|
||||
| **存储** | `6Gi` | PVC `postgres-data` |
|
||||
| **CPU** | `100m` 请求 / `500m` 上限 | StatefulSet `resources` 字段 |
|
||||
| **内存** | `256Mi` 请求 / `512Mi` 上限 | StatefulSet `resources` 字段 |
|
||||
|
||||
> **注意:** 密码当前以明文形式存储在 `pg-configmap.yaml` 中,生产环境应将其迁移至 K8s Secret,并通过环境变量注入容器,避免将明文密码提交至版本库。
|
||||
|
||||
##### 4.4.1 等待 Pod 就绪
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ spec:
|
|||
containers:
|
||||
- name: grafana
|
||||
image: grafana/grafana:10.4.2
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
- containerPort: 3000
|
||||
env:
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ spec:
|
|||
containers:
|
||||
- name: jaeger
|
||||
image: jaegertracing/all-in-one:1.56
|
||||
imagePullPolicy: IfNotPresent
|
||||
env:
|
||||
- name: COLLECTOR_OTLP_ENABLED
|
||||
value: "true"
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ spec:
|
|||
containers:
|
||||
- name: loki
|
||||
image: grafana/loki:2.9.4
|
||||
imagePullPolicy: IfNotPresent
|
||||
args:
|
||||
- -config.file=/etc/loki/loki.yaml
|
||||
ports:
|
||||
|
|
|
|||
|
|
@ -34,9 +34,9 @@ spec:
|
|||
- mongosh
|
||||
- --eval
|
||||
- "db.adminCommand('ping')"
|
||||
initialDelaySeconds: 10
|
||||
periodSeconds: 5
|
||||
timeoutSeconds: 3
|
||||
initialDelaySeconds: 30
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 10
|
||||
failureThreshold: 12
|
||||
livenessProbe:
|
||||
exec:
|
||||
|
|
@ -44,10 +44,10 @@ spec:
|
|||
- mongosh
|
||||
- --eval
|
||||
- "db.adminCommand('ping')"
|
||||
initialDelaySeconds: 30
|
||||
periodSeconds: 20
|
||||
timeoutSeconds: 3
|
||||
failureThreshold: 3
|
||||
initialDelaySeconds: 120
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 30
|
||||
failureThreshold: 5
|
||||
resources:
|
||||
requests:
|
||||
cpu: 100m
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ spec:
|
|||
containers:
|
||||
- name: promtail
|
||||
image: grafana/promtail:2.9.4
|
||||
imagePullPolicy: IfNotPresent
|
||||
args:
|
||||
- -config.file=/etc/promtail/promtail.yaml
|
||||
ports:
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ spec:
|
|||
containers:
|
||||
- name: rabbitmq
|
||||
image: rabbitmq:4.1.1-management-alpine
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
- containerPort: 4369
|
||||
- containerPort: 5671
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ spec:
|
|||
containers:
|
||||
- name: redis
|
||||
image: redis/redis-stack-server:latest
|
||||
imagePullPolicy: IfNotPresent
|
||||
resources:
|
||||
limits:
|
||||
memory: "128Mi"
|
||||
|
|
|
|||
|
|
@ -65,9 +65,7 @@ func (g *Graph) AddEdge(from, to uuid.UUID) {
|
|||
|
||||
// 创建新的拓扑信息时,如果被链接的点已经存在于游离节点中
|
||||
// 则将其移除
|
||||
if _, exist := g.FreeVertexs[toKey]; exist {
|
||||
delete(g.FreeVertexs, toKey)
|
||||
}
|
||||
delete(g.FreeVertexs, toKey)
|
||||
}
|
||||
|
||||
// DelNode delete a node to the graph
|
||||
|
|
|
|||
|
|
@ -47,8 +47,7 @@ func newLokiSyncer(lCfg config.LokiConfig) *lokiSyncer {
|
|||
client: &http.Client{Timeout: 5 * time.Second},
|
||||
ch: make(chan string, 512),
|
||||
}
|
||||
ls.wg.Add(1)
|
||||
go ls.run()
|
||||
ls.wg.Go(ls.run)
|
||||
return ls
|
||||
}
|
||||
|
||||
|
|
@ -70,7 +69,6 @@ func (ls *lokiSyncer) Sync() error {
|
|||
}
|
||||
|
||||
func (ls *lokiSyncer) run() {
|
||||
defer ls.wg.Done()
|
||||
ticker := time.NewTicker(2 * time.Second)
|
||||
defer ticker.Stop()
|
||||
|
||||
|
|
|
|||
|
|
@ -185,13 +185,11 @@ func (w *TaskWorker) Start() error {
|
|||
|
||||
// Start multiple consumers for better throughput
|
||||
for i := 0; i < w.cfg.QueueConsumerCount; i++ {
|
||||
w.wg.Add(1)
|
||||
go w.consumerLoop(i)
|
||||
w.wg.Go(func() { w.consumerLoop(i) })
|
||||
}
|
||||
|
||||
// Start health check goroutine
|
||||
w.wg.Add(1)
|
||||
go w.healthCheckLoop()
|
||||
w.wg.Go(w.healthCheckLoop)
|
||||
|
||||
logger.Info(w.ctx, "task worker started successfully")
|
||||
return nil
|
||||
|
|
@ -199,8 +197,6 @@ func (w *TaskWorker) Start() error {
|
|||
|
||||
// consumerLoop runs a single RabbitMQ consumer
|
||||
func (w *TaskWorker) consumerLoop(consumerID int) {
|
||||
defer w.wg.Done()
|
||||
|
||||
logger.Info(w.ctx, "starting consumer", "consumer_id", consumerID)
|
||||
|
||||
// Consume messages from the queue
|
||||
|
|
@ -478,8 +474,6 @@ func (w *TaskWorker) dispatch(ctx context.Context, taskType TaskType, taskID uui
|
|||
|
||||
// healthCheckLoop periodically checks worker health and metrics
|
||||
func (w *TaskWorker) healthCheckLoop() {
|
||||
defer w.wg.Done()
|
||||
|
||||
ticker := time.NewTicker(w.cfg.PollingInterval)
|
||||
defer ticker.Stop()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue