How zoyaumar/kubernetes-ops-assistant works
Purpose and system shape
Kubernetes Ops Assistant is an event-driven, Kubernetes-native RAG system: it captures cluster events/logs, indexes evidence in PostgreSQL/pgvector, and answers incident questions with cited LLM responses. The main executable services are the watcher, indexer, and Node/TypeScript API; React is the user entry point.
Cluster ingestion boundary
The watcher is the boundary to the Kubernetes API. It uses a least-privilege Kubernetes client to observe deployments, pods, events, and logs, normalizes them into shared cluster-event schemas, and publishes them to NATS JetStream.
• apps/watcher/app/main.py
• apps/watcher/app/watchers/pods.py
• apps/watcher/app/publishers/nats_publisher.py
Durable event transport and scaling
NATS JetStream decouples cluster observation from indexing. The consumer model is at-least-once: messages are only acknowledged after persistence, so failures trigger redelivery. The indexer is intended to be KEDA-scaled from queue backlog; failed messages have a DLQ handling path.
• apps/indexer/app/consumers/nats_consumer.py
• apps/indexer/app/dlq/handler.py
• k8s/keda/indexer-scaledobject.yaml
Indexing and persistence pipeline
The Python indexer consumes cluster events, normalizes, deduplicates, chunks text, generates local embeddings, and writes event/conversation-related evidence and vectors to PostgreSQL with pgvector. Database uniqueness plus stable event identity make redelivery idempotent.
• apps/indexer/app/main.py
• apps/indexer/app/processing/deduplicate.py
• apps/indexer/app/repositories/embeddings.py
• db/schema.sql
API and RAG orchestration
The Node API is the synchronous application boundary for clients. Chat routes invoke a RAG orchestrator that combines structured filtering, time-aware retrieval, vector similarity, ranking, prompt construction, citation formatting, and an LLM provider. API routes also expose auth, conversation, cluster, and health concerns.
• apps/api/src/server.ts
• apps/api/src/routes/chat.ts
• apps/api/src/rag/orchestrator.ts
• apps/api/src/rag/retrieval.ts
Model-provider boundaries
Generation is behind a provider interface, with Groq and mock implementations; embeddings are independently abstracted in the indexer and currently support a local provider. This separates the retrieval/prompt pipeline from external LLM availability and model choices.
• apps/api/src/llm/provider.ts
• apps/api/src/llm/groq.ts
• apps/indexer/app/embeddings/provider.py
User access and deployment platform
The React/Vite frontend calls the API; API middleware supplies authentication, request IDs, and centralized errors. Services are containerized and deployed to kind/Kubernetes alongside PostgreSQL, NATS, RBAC/service accounts, and service manifests. Prometheus, Grafana, and OpenTelemetry are provisioned for observability.
• frontend/src/app/App.tsx
• apps/api/src/middleware/auth.ts
• k8s/base/rbac.yaml
• k8s/observability/otel-collector.yaml
Main entry points: app/main.py Watcher · app/main.py Indexer · server.ts Node API · nats_consumer.py JetStream consumer
Components 22
Cluster ingestion
- Kubernetes API · Deployments, pods, events, and logs.
- Watcher · Observes and normalizes cluster evidence.
apps/watcher/app/main.py - Pod watcher
apps/watcher/app/watchers/pods.py - RBAC and service account · Least-privilege access for cluster observation.
k8s/base/rbac.yaml - NATS publisher
apps/watcher/app/publishers/nats_publisher.py
Event pipeline
- NATS JetStream · At-least-once delivery decouples observation from indexing.
- Indexer · Persists idempotent evidence and vector records.
apps/indexer/app/main.py - JetStream consumer · Acknowledges only after persistence.
apps/indexer/app/consumers/nats_consumer.py - Evidence processing · Deduplicates events, chunks text, and creates stable evidence.
apps/indexer/app/processing/deduplicate.py - Embedding provider · Local embeddings are generated independently of LLM generation.
apps/indexer/app/embeddings/provider.py - DLQ handler · Handles messages that cannot be indexed.
apps/indexer/app/dlq/handler.py
Application and RAG
- React frontend
frontend/src/app/App.tsx - Node API · Exposes chat, auth, conversations, cluster, and health routes.
apps/api/src/server.ts - API middleware · Supplies authentication, request IDs, and centralized errors.
apps/api/src/middleware/auth.ts - Chat routes
apps/api/src/routes/chat.ts - RAG orchestrator · Builds ranked, cited answers from filtered evidence.
apps/api/src/rag/orchestrator.ts - Retrieval
apps/api/src/rag/retrieval.ts - LLM provider interface · Supports Groq and mock implementations.
apps/api/src/llm/provider.ts - Groq provider
apps/api/src/llm/groq.ts
Platform services
- PostgreSQL + pgvector · Stores evidence, conversations, and vectors with uniqueness constraints.
db/schema.sql - KEDA scaler · Scales indexers from queue backlog.
k8s/keda/indexer-scaledobject.yaml - OpenTelemetry collector · Feeds provisioned observability tooling.
k8s/observability/otel-collector.yaml
Connections 24
- RBAC and service account → Watcher: authorizes
- Kubernetes API → Pod watcher: pods and events
- Pod watcher → Watcher: normalized observations
- Watcher → NATS publisher: cluster events
- NATS publisher → NATS JetStream: publishes
- NATS JetStream → JetStream consumer: durable delivery
- JetStream consumer → Indexer: messages
- Indexer → Evidence processing: processes
- Evidence processing → Embedding provider: chunks
- Embedding provider → PostgreSQL + pgvector: vectors
- Evidence processing → PostgreSQL + pgvector: idempotent evidence
- JetStream consumer → DLQ handler: failed messages
- KEDA scaler → Indexer: scales on backlog
- React frontend → Node API: client requests
- API middleware → Node API: protects
- Node API → Chat routes: routes chat
- Chat routes → RAG orchestrator: questions
- RAG orchestrator → Retrieval: retrieves evidence
- Retrieval → PostgreSQL + pgvector: filtered vector search
- RAG orchestrator → LLM provider interface: generation request
- LLM provider interface → Groq provider: implementation
- Watcher → OpenTelemetry collector: telemetry
- Indexer → OpenTelemetry collector: telemetry
- Node API → OpenTelemetry collector: telemetry