Skip to content

Commit 5fd42d8

Browse files
committed
kube fixes
1 parent 42c64c7 commit 5fd42d8

File tree

10 files changed

+107
-32
lines changed

10 files changed

+107
-32
lines changed

deploy/kubernetes/deploy.sh

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -186,24 +186,39 @@ apply_with_kustomize() {
186186
tmp_dir="$(mktemp -d)"
187187
log_info "Building temporary kustomize overlay at ${tmp_dir}"
188188

189+
# Copy manifests to temp dir to avoid absolute path issues
190+
cp namespace.yaml configmap.yaml qdrant.yaml mcp-memory.yaml mcp-indexer.yaml \
191+
mcp-http.yaml indexer-services.yaml rbac.yaml hpa.yaml networkpolicy.yaml "${tmp_dir}/"
192+
193+
if [[ "${SKIP_LLAMACPP}" != "true" ]]; then
194+
cp llamacpp.yaml "${tmp_dir}/"
195+
fi
196+
197+
if [[ "${DEPLOY_INGRESS}" == "true" ]]; then
198+
cp ingress.yaml "${tmp_dir}/"
199+
fi
200+
189201
# Compose resources list based on flags
190202
{
191203
echo "apiVersion: kustomize.config.k8s.io/v1beta1"
192204
echo "kind: Kustomization"
193205
echo "namespace: ${NAMESPACE}"
194206
echo "resources:"
195-
echo " - ${base_dir}/namespace.yaml"
196-
echo " - ${base_dir}/configmap.yaml"
197-
echo " - ${base_dir}/qdrant.yaml"
198-
echo " - ${base_dir}/mcp-memory.yaml"
199-
echo " - ${base_dir}/mcp-indexer.yaml"
200-
echo " - ${base_dir}/mcp-http.yaml"
201-
echo " - ${base_dir}/indexer-services.yaml"
207+
echo " - namespace.yaml"
208+
echo " - configmap.yaml"
209+
echo " - qdrant.yaml"
210+
echo " - mcp-memory.yaml"
211+
echo " - mcp-indexer.yaml"
212+
echo " - mcp-http.yaml"
213+
echo " - indexer-services.yaml"
214+
echo " - rbac.yaml"
215+
echo " - hpa.yaml"
216+
echo " - networkpolicy.yaml"
202217
if [[ "${SKIP_LLAMACPP}" != "true" ]]; then
203-
echo " - ${base_dir}/llamacpp.yaml"
218+
echo " - llamacpp.yaml"
204219
fi
205220
if [[ "${DEPLOY_INGRESS}" == "true" ]]; then
206-
echo " - ${base_dir}/ingress.yaml"
221+
echo " - ingress.yaml"
207222
fi
208223
echo "images:"
209224
echo " - name: context-engine"
@@ -214,6 +229,9 @@ apply_with_kustomize() {
214229
log_info "Applying kustomize overlay"
215230
kubectl apply -k "${tmp_dir}"
216231
log_success "Applied manifests via kustomize"
232+
233+
# Clean up temp dir
234+
rm -rf "${tmp_dir}"
217235
}
218236

219237

deploy/kubernetes/hpa.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
apiVersion: autoscaling/v2
3+
kind: HorizontalPodAutoscaler
4+
metadata:
5+
name: mcp-indexer-hpa
6+
namespace: context-engine
7+
spec:
8+
scaleTargetRef:
9+
apiVersion: apps/v1
10+
kind: Deployment
11+
name: mcp-indexer
12+
minReplicas: 1
13+
maxReplicas: 5
14+
metrics:
15+
- type: Resource
16+
resource:
17+
name: cpu
18+
target:
19+
type: Utilization
20+
averageUtilization: 70
21+

deploy/kubernetes/indexer-services.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ spec:
2121
app: context-engine
2222
component: watcher
2323
spec:
24+
serviceAccountName: context-engine
25+
2426
containers:
2527
- name: watcher
2628
image: context-engine:latest
@@ -103,6 +105,7 @@ spec:
103105
app: context-engine
104106
component: indexer
105107
spec:
108+
serviceAccountName: context-engine
106109
restartPolicy: OnFailure
107110
containers:
108111
- name: indexer
@@ -160,6 +163,7 @@ spec:
160163
app: context-engine
161164
component: init
162165
spec:
166+
serviceAccountName: context-engine
163167
restartPolicy: OnFailure
164168
containers:
165169
- name: init-payload

deploy/kubernetes/kustomization.yaml

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ resources:
2020

2121
# Indexer services
2222
- indexer-services.yaml
23+
- rbac.yaml
24+
- networkpolicy.yaml
25+
26+
- hpa.yaml
27+
2328

2429
# Optional services
2530
- llamacpp.yaml
@@ -33,26 +38,17 @@ labels:
3338
app.kubernetes.io/managed-by: kustomize
3439

3540
# Patches for production customization
36-
patchesStrategicMerge:
37-
# Uncomment and create patches for production
38-
# - patches/production-storage.yaml
39-
# - patches/production-resources.yaml
40-
# - patches/production-ingress.yaml
41+
patchesStrategicMerge: []
4142

4243
# ConfigMap generator (optional - for overrides)
4344
configMapGenerator:
4445
- name: context-engine-overrides
45-
literals:
46-
# Override specific values here
47-
# COLLECTION_NAME=production-collection
48-
# EMBEDDING_MODEL=BAAI/bge-large-en-v1.5
46+
literals: []
4947

5048
# Secret generator (optional - for sensitive data)
5149
secretGenerator:
5250
- name: context-engine-secrets
53-
literals:
54-
# Add secrets here (recommended to use existing secrets instead)
55-
# QDRANT_API_KEY=your-api-key
51+
literals: []
5652

5753
# Images configuration (customize for your registry)
5854
images:

deploy/kubernetes/llamacpp.yaml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ spec:
6666
mountPath: /models
6767
resources:
6868
requests:
69-
memory: "256Mi"
69+
memory: "512Mi"
7070
cpu: "100m"
7171
limits:
72-
memory: "512Mi"
72+
memory: "2Gi"
7373
cpu: "500m"
7474

7575
containers:
@@ -87,16 +87,18 @@ spec:
8787
containerPort: 8080
8888
protocol: TCP
8989
command:
90-
- sh
91-
- -c
90+
- /app/llama-server
9291
args:
93-
- |
94-
exec /llama-server \
95-
--host 0.0.0.0 \
96-
--port 8080 \
97-
--model "/models/${LLAMACPP_MODEL_NAME}" \
98-
--ctx-size 4096 \
99-
--n-gpu-layers 0
92+
- --host
93+
- "0.0.0.0"
94+
- --port
95+
- "8080"
96+
- --model
97+
- /models/qwen2.5-1.5b-instruct-q8_0.gguf
98+
- --ctx-size
99+
- "4096"
100+
- --n-gpu-layers
101+
- "0"
100102
resources:
101103
requests:
102104
memory: "2Gi"

deploy/kubernetes/mcp-http.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ spec:
2020
app: context-engine
2121
component: mcp-memory-http
2222
spec:
23+
serviceAccountName: context-engine
24+
2325
containers:
2426
- name: mcp-memory-http
2527
image: context-engine:latest
@@ -162,6 +164,7 @@ spec:
162164
app: context-engine
163165
component: mcp-indexer-http
164166
spec:
167+
serviceAccountName: context-engine
165168
containers:
166169
- name: mcp-indexer-http
167170
image: context-engine:latest

deploy/kubernetes/mcp-indexer.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ spec:
2020
app: context-engine
2121
component: mcp-indexer
2222
spec:
23+
serviceAccountName: context-engine
24+
2325
containers:
2426
- name: mcp-indexer
2527
image: context-engine:latest

deploy/kubernetes/mcp-memory.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ spec:
2020
app: context-engine
2121
component: mcp-memory
2222
spec:
23+
serviceAccountName: context-engine
24+
2325
containers:
2426
- name: mcp-memory
2527
image: context-engine:latest
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
apiVersion: networking.k8s.io/v1
3+
kind: NetworkPolicy
4+
metadata:
5+
name: allow-intra-namespace-ingress-internal
6+
namespace: context-engine
7+
spec:
8+
podSelector:
9+
matchLabels:
10+
app: context-engine
11+
matchExpressions:
12+
- key: component
13+
operator: In
14+
values: ["watcher", "indexer", "init"]
15+
policyTypes:
16+
- Ingress
17+
ingress:
18+
- from:
19+
- podSelector: {}
20+

deploy/kubernetes/rbac.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
apiVersion: v1
3+
kind: ServiceAccount
4+
metadata:
5+
name: context-engine
6+
namespace: context-engine
7+

0 commit comments

Comments
 (0)