@@ -11,35 +11,59 @@ This directory contains Kubernetes manifests for deploying Context Engine on a r
1111
1212## Architecture
1313
14- ```
15- ┌─────────────────────────────────────────────────────────────┐
16- │ Kubernetes Cluster │
17- │ │
18- │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
19- │ │ Qdrant │ │ Memory MCP │ │ Indexer MCP │ │
20- │ │ StatefulSet │ │ Deployment │ │ Deployment │ │
21- │ │ Port: 6333 │ │ Port: 8000 │ │ Port: 8001 │ │
22- │ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘ │
23- │ │ │ │ │
24- │ │ ┌─────────────┴──────────────────┘ │
25- │ │ │ │
26- │ ┌──────▼────▼──────────────────────────────────────────┐ │
27- │ │ PersistentVolume (qdrant-storage) │ │
28- │ └───────────────────────────────────────────────────────┘ │
29- │ │
30- │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
31- │ │ Watcher │ │ Watcher │ │ Watcher │ │
32- │ │ (repo-1) │ │ (repo-2) │ │ (repo-3) │ │
33- │ │ Deployment │ │ Deployment │ │ Deployment │ │
34- │ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘ │
35- │ │ │ │ │
36- │ ┌──────▼──────────────────▼──────────────────▼─────────┐ │
37- │ │ HostPath Volume (repos) │ │
38- │ │ /tmp/context-engine-repos/repo-1/ │ │
39- │ │ /tmp/context-engine-repos/repo-2/ │ │
40- │ │ /tmp/context-engine-repos/repo-3/ │ │
41- │ └───────────────────────────────────────────────────────┘ │
42- └─────────────────────────────────────────────────────────────┘
14+ ``` mermaid
15+ graph TB
16+ subgraph cluster["Kubernetes Cluster (namespace: context-engine)"]
17+ subgraph ingress["Ingress Layer"]
18+ nginx["NGINX Ingress<br/>Routes: /qdrant, /mcp/*, /mcp-http/*, /llamacpp"]
19+ end
20+
21+ subgraph services["Core Services"]
22+ qdrant["Qdrant StatefulSet<br/>Port: 6333<br/>Vector Database"]
23+
24+ subgraph mcp["MCP Services (4 Deployments)"]
25+ mcp_mem_sse["Memory SSE<br/>Port: 8000"]
26+ mcp_mem_http["Memory HTTP<br/>Port: 8002"]
27+ mcp_idx_sse["Indexer SSE<br/>Port: 8001<br/>(HPA: 1-5 replicas)"]
28+ mcp_idx_http["Indexer HTTP<br/>Port: 8003"]
29+ end
30+
31+ llama["Llama.cpp Deployment<br/>Port: 8080<br/>Init: Model Download"]
32+ watcher["Watcher Deployment<br/>Watches: /work"]
33+ end
34+
35+ subgraph security["Security & Scaling"]
36+ rbac["RBAC: ServiceAccount<br/>(context-engine)"]
37+ netpol["NetworkPolicy<br/>Intra-namespace ingress<br/>for watcher/indexer/init"]
38+ hpa["HPA: mcp-indexer<br/>1-5 replicas @ 70% CPU"]
39+ end
40+
41+ subgraph storage["Persistent Storage (HostPath)"]
42+ qdrant_vol["Qdrant Data<br/>/tmp/context-engine-qdrant"]
43+ models_vol["LLM Models<br/>/tmp/context-engine-models"]
44+ repos_vol["Repositories<br/>/tmp/context-engine-repos"]
45+ end
46+ end
47+
48+ nginx --> qdrant
49+ nginx --> mcp
50+ nginx --> llama
51+
52+ mcp --> qdrant
53+ llama -.-> mcp
54+ watcher --> qdrant
55+
56+ qdrant --> qdrant_vol
57+ llama --> models_vol
58+ watcher --> repos_vol
59+
60+ style nginx fill:#e1f5ff
61+ style qdrant fill:#fff4e1
62+ style mcp fill:#e8f5e9
63+ style llama fill:#f3e5f5
64+ style watcher fill:#fce4ec
65+ style security fill:#fff9c4
66+ style storage fill:#e0e0e0
4367```
4468
4569## Quick Start
@@ -75,16 +99,26 @@ images:
7599### 3. Deploy Using Kustomize
76100
77101` ` ` bash
78- # Option 1: Using kubectl with kustomize
102+ # Option 1: Using the deploy script with Kustomize (recommended)
103+ ./deploy.sh --use-kustomize --registry your-registry/context-engine --tag latest --deploy-ingress
104+
105+ # Option 2: Using kubectl with kustomize directly
79106kubectl apply -k .
80107
81- # Option 2 : Using kustomize CLI
108+ # Option 3 : Using kustomize CLI
82109kustomize build . | kubectl apply -f -
83110
84- # Option 3 : Using the deploy script
85- ./deploy.sh --registry your-registry --tag latest
111+ # Option 4 : Using the deploy script without Kustomize (legacy)
112+ ./deploy.sh --registry your-registry/context-engine --tag latest --deploy-ingress
86113```
87114
115+ ** Deploy Script Flags:**
116+ - ` --use-kustomize ` : Use Kustomize for declarative image management (recommended)
117+ - ` --registry <registry/name> ` : Docker registry and image name (default: context-engine)
118+ - ` --tag <tag> ` : Image tag (default: latest)
119+ - ` --deploy-ingress ` : Deploy NGINX ingress routes
120+ - ` --skip-llamacpp ` : Skip llama.cpp decoder deployment
121+
88122### 4. Deploy Using Makefile
89123
90124``` bash
@@ -458,11 +492,35 @@ kubectl patch deployment -n context-engine mcp-indexer -p \
458492
459493# # Security Considerations
460494
461- 1. **Network Policies** : Restrict pod-to-pod communication
462- 2. **RBAC** : Limit service account permissions
463- 3. **Secrets Management** : Use Kubernetes secrets or external secret managers
464- 4. **TLS** : Enable TLS for external access via Ingress
465- 5. **Resource Quotas** : Set namespace resource quotas
495+ # ## Implemented Security Features
496+
497+ 1. **RBAC (Role-Based Access Control)**
498+ - ServiceAccount : ` context-engine` created in `rbac.yaml`
499+ - Applied to all Deployments and Jobs
500+ - Provides pod identity for Kubernetes API authentication
501+ - Future : Add Role/RoleBinding for fine-grained permissions
502+
503+ 2. **NetworkPolicy (Soft Hardening - Option B)**
504+ - Policy : ` allow-intra-namespace-ingress-internal` in `networkpolicy.yaml`
505+ - Scope : Applies to watcher, indexer, and init pods
506+ - Rules : Allows ingress only from pods in the same namespace
507+ - No egress restrictions (external downloads and Qdrant access work)
508+ - MCP services and Qdrant remain accessible via Ingress/NodePort
509+ - Future : Implement Option A (default-deny with explicit allow rules)
510+
511+ 3. **HorizontalPodAutoscaler (HPA)**
512+ - Target : mcp-indexer deployment
513+ - Min replicas : 1, Max replicas: 5
514+ - Trigger : 70% CPU utilization
515+ - Prevents resource exhaustion under load
516+
517+ # ## Additional Security Recommendations
518+
519+ 4. **Secrets Management** : Use Kubernetes secrets or external secret managers for sensitive data
520+ 5. **TLS** : Enable TLS for external access via Ingress with cert-manager
521+ 6. **Resource Quotas** : Set namespace resource quotas to prevent resource exhaustion
522+ 7. **Pod Security Standards** : Apply restricted pod security standards
523+ 8. **Image Security** : Use signed images and vulnerability scanning
466524
467525# # See Also
468526
0 commit comments