How rajinikanthvadla-ai/aiops-slack-chat-project works
1. What this repo is
- This is a containerized Slack bot for Kubernetes operations.
- The core architecture is a small Python application that sits between three external systems: Slack, the Kubernetes API, and Google Gemini for analysis.
2. Primary runtime entrypoint
- main.py is the application entrypoint.
- It likely bootstraps configuration, logging, and the Slack bot runtime, then starts the long-lived process inside the container.
3. Slack-facing subsystem
- src/slack_bot.py is the interaction layer for Slack events and messages.
- The README indicates Socket Mode and bot token-based auth, so the bot listens for mentions/DMs and replies in channels rather than exposing a public webhook.
- Channel access is restricted through ALLOWED_CHANNELS, which is a key policy boundary.
4. Natural-language command layer
- src/command_parser.py converts free-form user requests like “show me pods in kube-system” into structured actions.
- This is the main request-routing boundary: it decides whether a message is a namespace listing, pod query, log retrieval, describe command, or cluster-status request.
5. Kubernetes operations layer
- src/kubernetes_executor.py is the cluster access layer.
- It is responsible for read-only Kubernetes API calls such as listing namespaces, pods, services, fetching logs, describing resources, and gathering cluster health data.
- This subsystem is intentionally constrained by RBAC, which makes it the security boundary for all cluster interactions.
6. AI analysis layer
- src/llm_analyzer.py takes raw operational output, especially logs and cluster-state data, and turns it into health summaries, issue detection, root-cause hints, and remediation guidance.
- The README shows that Gemini is the external model provider, so the bot has a second outbound dependency besides Kubernetes and Slack.
- This analysis stage is additive: it does not execute changes, only interprets data and recommends actions.
7. Configuration boundary
- src/config.py centralizes environment-driven settings such as Slack tokens, Gemini API key, allowed channels, default namespace, debug mode, and port.
- This file is likely the single source of truth for runtime configuration, keeping secrets and deployment-specific values out of the code path.
8. End-to-end data flow
- A Slack message enters the bot.
- The message is filtered by bot/channel policy, then parsed into an intent.
- If it maps to a Kubernetes command, the executor queries the cluster.
- If the command includes logs or health data, the raw output is passed to the LLM analyzer.
- The final response is formatted and sent back to Slack.
9. Infrastructure and deployment model
- The bot is designed to run in Kubernetes using the manifests under kubernetes/.
- deployment.yaml defines the workload, service.yaml exposes the pod internally, rbac.yaml grants least-privilege read access, and secrets.yaml stores credentials.
- The README’s health endpoints and port 3000 suggest the container also exposes internal readiness/health checks for Kubernetes probes and monitoring.
10. Security and access model
- The repo is explicitly read-only: no mutating Kubernetes actions are part of the intended architecture.
- Security relies on three gates: Slack channel allowlisting, Kubernetes RBAC, and Kubernetes Secrets for credentials.
- The bot is intended to run as a non-root container, which is part of the operational trust boundary.
11. Supporting scripts and ops workflow
- scripts/healthcheck.py and scripts/cleanup.sh support operational validation and teardown.
- killercoda-quickstart.sh appears to automate demo or lab deployment, tying together build, cluster setup, and app installation.
- QUICKSTART.md and the README document the operator workflow, but they do not change the runtime architecture.
12. Containerization and packaging
- Dockerfile packages the Python app for deployment.
- requirements.txt captures the Python dependencies, which are likely Slack SDK, Kubernetes client, and Gemini-related libraries.
- The architecture is therefore: Python service in a container, deployed to Kubernetes, interacting with Slack over the network and with the cluster through the in-cluster service account.
13. Important architectural boundaries to draw
- External user boundary: Slack users in allowed channels.
- Application boundary: Slack event handling and command parsing.
- Cluster boundary: Kubernetes API access under RBAC-limited service account.
- AI boundary: outbound analysis requests to Gemini.
- Operational boundary: health/readiness endpoints and Kubernetes probes.
14. What is intentionally not in the system
- There is no evidence of a database, job queue, or persistent state layer.
- The bot appears stateless beyond runtime configuration and live API calls, which keeps the diagram simple: message in, cluster query, optional AI analysis, response out.
Main entry points: slack_bot.py Slack bot · deployment.yaml Deployment · kubernetes_executor.py K8s exec · llm_analyzer.py LLM analyzer
Components 18
Runtime
Core Python application and request handling
- main · Bootstraps config, logging, and the bot runtime
main.py - Config · Environment-driven runtime settings and secrets wiring
src/config.py - Slack bot · Receives Slack events, enforces channel policy, and sends replies
src/slack_bot.py - Parser · Converts free-form requests into structured command intents
src/command_parser.py
Integrations
External systems and service boundaries
- K8s exec · Runs read-only Kubernetes API operations and gathers cluster state
src/kubernetes_executor.py - LLM analyzer · Summarizes logs and cluster data into findings and guidance
src/llm_analyzer.py - Slack · Slack users, channels, and Socket Mode delivery
- Kubernetes API · Cluster control plane accessed through least-privilege RBAC
- Gemini · Outbound model provider for operational analysis
Deployment
Container, Kubernetes manifests, and operational setup
- Container · Packages the Python service for container deployment
Dockerfile - Deps · Python dependency set for Slack, Kubernetes, and AI integration
requirements.txt - Deployment · Runs the bot container in Kubernetes
kubernetes/deployment.yaml - Service · Internal service endpoint for the pod
kubernetes/service.yaml - RBAC · Read-only cluster permissions for the service account
kubernetes/rbac.yaml - Secrets · Stores credentials and API keys for runtime access
kubernetes/secrets.yaml
Operations
Health checks, cleanup, and quickstart automation
- Healthcheck · Validates container and service readiness
scripts/healthcheck.py - Cleanup · Removes demo or lab resources
scripts/cleanup.sh - Quickstart · Automates demo deployment and setup
killercoda-quickstart.sh
Connections 21
- main → Config: loads · Initial runtime configuration
- main → Slack bot: starts · Launches the long-lived bot process
- Slack bot → Slack: connects to · Receives and sends Slack messages
- Slack bot → Parser: routes messages to · Turns user text into structured intents
- Parser → K8s exec: dispatches queries · Maps intents to cluster operations
- Parser → LLM analyzer: dispatches analysis · Selects AI-backed interpretation when needed
- K8s exec → Kubernetes API: calls · Performs read-only cluster queries
- K8s exec → LLM analyzer: supplies data to · Passes logs and state for analysis
- LLM analyzer → Gemini: calls · Sends analysis prompts and data
- Slack bot → Config: checks policy · Uses allowed channels and runtime settings
- Slack bot → K8s exec: executes commands · Invokes Kubernetes reads on behalf of users
- Slack bot → LLM analyzer: summarizes results · Adds AI-generated operational insight
- Container → Deps: bundles · Builds the runtime image from Python dependencies
- Container → main: runs · Container entrypoint starts the app
- Deployment → Container: deploys image · Kubernetes workload uses the built container
- Deployment → Service: exposes · Creates an internal service for the pod
- Deployment → RBAC: uses · Attaches least-privilege permissions
- Deployment → Secrets: mounts · Injects runtime credentials
- Healthcheck → Service: probes · Checks readiness and liveness surfaces
- Quickstart → Deployment: installs · Automates demo deployment workflow
- Cleanup → Deployment: removes · Tears down demo resources