How tentens-tech/process-wrapper works
Project Type and Purpose
• This is a Go-based CLI/sidecar binary designed to run inside a container pod.
• It manages multiple child processes, handles their lifecycle and health checks, exposes liveness/readiness/metrics HTTP endpoints, and integrates with Kubernetes (kubelet), Prometheus, Elasticsearch, a metrics-server, Envoy, Google preemption metadata, and an optional shared-lock service.
a. Config Loader (pkg/config)
b. Process Manager & Probes (pkg/process)
• Child Process Spawner
• Health-Check Plugins (HTTP, TCP, exec, file, env, SQL, floating-PID, heartbeat)
• Stdout/Stderr Interceptor & Logfmt Formatter
• PostStart Hooks
c. Signal Handler (pkg/signals)
d. Lease Manager (pkg/lease)
• Shared-lock client/server, Etcd integration
e. Metrics & Stats (pkg/metrics, pkg/stat)
• Prometheus metrics endpoint
• UDP metrics-server client
• Elasticsearch event publisher
f. HTTP API Server (main.go + net/http)
• /liveness and /readiness endpoints
• /metrics and /prommerge endpoints
g. CLI Entry Point (main.go)
Architectural Patterns & Design Principles
• Monolithic binary with clear internal layering (config → core → HTTP/metrics)
• Plugin-style probes for extensibility
• Separation of concerns: config, process, signals, metrics, lease
• Use of standard Go concurrency primitives (goroutines, channels) for lifecycle control
• Sidecar pattern for container orchestration
Essential Elements Checklist
• Clear component labels
• Notes on key configurations (ENV variables, YAML config)