How airwallex/k8s-pod-restart-info-collector works
Main Components
• Controller (Go Binary): This is the heart of the system. Key files such as main.go, controller.go, slack.go, and helpers.go indicate that the controller watches Kubernetes pods and processes their events.
• Kubernetes Cluster: Represent the Kubernetes API server, which feeds pod events to the controller. Include typical components like Pod objects, Deployments, and the custom resource access (if any).
• Slack Integration: This component is external to the cluster. The controller utilizes a Slack webhook (configured via environment variables/Helm values) to send pod restart messages and detailed notifications.
• Helm Deployment: The helm directory and shell-version-for-poc folder contain Helm charts and templates for deploying the controller, managing RBAC, secrets, and configmaps. This should be noted as the packaging/deployment mechanism.
Relationships and Data Flow
• The Kubernetes API Server notifies the custom controller about pod events/changes.
• The Controller processes pod restart events and collects data (logs, events, statuses).
• After processing, the controller sends a request (using HTTP/S) to the Slack webhook URL.
• Deployment and configuration management is handled via Helm templates that define Kubernetes resources like Deployments, RBAC, ConfigMaps, and Secrets.
• Optionally, show the build and Docker container image (indicated by Dockerfile and build.sh) that encapsulates the controller.
Architectural Patterns and Design Principles
• Event-Driven Architecture: The controller listens to events from the K8s API and then reacts on pod status changes.
• Separation of Concerns: The code is divided between event collection, data processing, and notification (Slack) logic.
• Containerization & Helm: The Dockerfile and Helm charts indicate standard container orchestration with deployment configuration separated from business logic.
Technologies & Frameworks to Mention
• Go Language – the core implementation.
• Kubernetes – for pod management and event watching.
• Helm – for packaging and deploying the application into the cluster.
• Slack Webhook – for alerting users.
• Docker – for containerizing the application.
• GitHub Actions/CI configuration folder (.github) hints at continuous integration practices.