@@ -178,23 +178,67 @@ set_images() {
178178 log_success " Images set to ${full} and jobs refreshed"
179179}
180180
181+ # Build a temporary Kustomize overlay and apply it with images/flags respected
182+ apply_with_kustomize () {
183+ local base_dir
184+ base_dir=" $( pwd) "
185+ local tmp_dir
186+ tmp_dir=" $( mktemp -d) "
187+ log_info " Building temporary kustomize overlay at ${tmp_dir} "
188+
189+ # Compose resources list based on flags
190+ {
191+ echo " apiVersion: kustomize.config.k8s.io/v1beta1"
192+ echo " kind: Kustomization"
193+ echo " namespace: ${NAMESPACE} "
194+ 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"
202+ if [[ " ${SKIP_LLAMACPP} " != " true" ]]; then
203+ echo " - ${base_dir} /llamacpp.yaml"
204+ fi
205+ if [[ " ${DEPLOY_INGRESS} " == " true" ]]; then
206+ echo " - ${base_dir} /ingress.yaml"
207+ fi
208+ echo " images:"
209+ echo " - name: context-engine"
210+ echo " newName: ${IMAGE_REGISTRY} "
211+ echo " newTag: ${IMAGE_TAG} "
212+ } > " ${tmp_dir} /kustomization.yaml"
213+
214+ log_info " Applying kustomize overlay"
215+ kubectl apply -k " ${tmp_dir} "
216+ log_success " Applied manifests via kustomize"
217+ }
218+
219+
181220# Main deployment function
182221main () {
183222 log_info " Starting Context-Engine Kubernetes deployment"
184223
185224 # Check prerequisites
186225 check_kubectl
187226
188- # Deploy in order
189- create_namespace
190- deploy_config
191- deploy_core
192- deploy_mcp_servers
193- deploy_http_servers
194- deploy_indexer_services
195- deploy_llamacpp
196- deploy_ingress
197- set_images
227+ if [[ " $USE_KUSTOMIZE " == " true" ]]; then
228+ # Single-shot apply via kustomize overlay (respects flags and images)
229+ apply_with_kustomize
230+ else
231+ # Deploy in order via raw manifests
232+ create_namespace
233+ deploy_config
234+ deploy_core
235+ deploy_mcp_servers
236+ deploy_http_servers
237+ deploy_indexer_services
238+ deploy_llamacpp
239+ deploy_ingress
240+ set_images
241+ fi
198242
199243 # Show status
200244 show_status
@@ -212,6 +256,7 @@ show_help() {
212256 echo " -t, --tag TAG Docker image tag (default: latest)"
213257 echo " --skip-llamacpp Skip Llama.cpp deployment"
214258 echo " --deploy-ingress Deploy Ingress configuration"
259+ echo " --use-kustomize Apply via kustomize overlay (respects --registry/--tag and flags)"
215260 echo " --namespace NAMESPACE Kubernetes namespace (default: context-engine)"
216261 echo
217262 echo " Examples:"
@@ -244,6 +289,10 @@ while [[ $# -gt 0 ]]; do
244289 DEPLOY_INGRESS=true
245290 shift
246291 ;;
292+ --use-kustomize)
293+ USE_KUSTOMIZE=true
294+ shift
295+ ;;
247296 --namespace)
248297 NAMESPACE=" $2 "
249298 shift 2
0 commit comments