33.PHONY : local-dev-token
44.PHONY : local-logs local-logs-backend local-logs-frontend local-logs-operator local-shell local-shell-frontend
55.PHONY : local-test local-test-dev local-test-quick test-all local-url local-troubleshoot local-port-forward local-stop-port-forward
6- .PHONY : push-all registry-login setup-hooks remove-hooks lint check-minikube check-kind check-kubectl dev-bootstrap kind-rebuild kind-status
6+ .PHONY : push-all registry-login setup-hooks remove-hooks lint check-minikube check-kind check-kubectl check-local-context dev-bootstrap kind-rebuild kind-status
77.PHONY : e2e-test e2e-setup e2e-clean deploy-langfuse-openshift
88.PHONY : unleash-port-forward unleash-status
99.PHONY : setup-minio minio-console minio-logs minio-status
@@ -351,7 +351,7 @@ local-up: check-minikube check-kubectl ## Start local development environment (m
351351 @echo " • Run: $( COLOR_BOLD) make local-status$( COLOR_RESET) to check deployment"
352352 @echo " • Run: $( COLOR_BOLD) make local-logs$( COLOR_RESET) to view logs"
353353
354- local-down : check-kubectl # # Stop Ambient Code Platform (keep minikube running)
354+ local-down : check-kubectl check-local-context # # Stop Ambient Code Platform (keep minikube running)
355355 @echo " $( COLOR_BLUE) ▶$( COLOR_RESET) Stopping Ambient Code Platform..."
356356 @$(MAKE ) --no-print-directory local-stop-port-forward
357357 @kubectl delete namespace $(NAMESPACE ) --ignore-not-found=true --timeout=60s
@@ -401,13 +401,13 @@ local-sync-version: ## Sync version from git to local deployment manifests
401401 rm -f components/manifests/minikube/frontend-deployment.yaml.bak && \
402402 echo " $( COLOR_GREEN) ✓$( COLOR_RESET) Version synced to $$ VERSION"
403403
404- local-rebuild : # # Rebuild and reload all components
404+ local-rebuild : check-local-context # # Rebuild and reload all components
405405 @echo " $( COLOR_BOLD) 🔄 Rebuilding all components...$( COLOR_RESET) "
406406 @$(MAKE ) --no-print-directory _build-and-load
407407 @$(MAKE ) --no-print-directory _restart-all
408408 @echo " $( COLOR_GREEN) ✓$( COLOR_RESET) All components rebuilt and reloaded"
409409
410- local-reload-backend : # # Rebuild and reload backend only
410+ local-reload-backend : check-local-context # # Rebuild and reload backend only
411411 @echo " $( COLOR_BLUE) ▶$( COLOR_RESET) Rebuilding backend..."
412412 @cd components/backend && $(CONTAINER_ENGINE ) build -t $(BACKEND_IMAGE ) . > /dev/null 2>&1
413413 @$(CONTAINER_ENGINE ) tag $(BACKEND_IMAGE ) localhost/$(BACKEND_IMAGE ) 2> /dev/null || true
@@ -430,7 +430,7 @@ local-reload-backend: ## Rebuild and reload backend only
430430 echo " $( COLOR_GREEN) ✓$( COLOR_RESET) Backend port forward restarted" ; \
431431 fi
432432
433- local-reload-frontend : # # Rebuild and reload frontend only
433+ local-reload-frontend : check-local-context # # Rebuild and reload frontend only
434434 @echo " $( COLOR_BLUE) ▶$( COLOR_RESET) Rebuilding frontend..."
435435 @cd components/frontend && $(CONTAINER_ENGINE ) build -t $(FRONTEND_IMAGE ) . > /dev/null 2>&1
436436 @$(CONTAINER_ENGINE ) tag $(FRONTEND_IMAGE ) localhost/$(FRONTEND_IMAGE ) 2> /dev/null || true
@@ -454,7 +454,7 @@ local-reload-frontend: ## Rebuild and reload frontend only
454454 fi
455455
456456
457- local-reload-operator : # # Rebuild and reload operator only
457+ local-reload-operator : check-local-context # # Rebuild and reload operator only
458458 @echo " $( COLOR_BLUE) ▶$( COLOR_RESET) Rebuilding operator..."
459459 @cd components/operator && $(CONTAINER_ENGINE ) build -t $(OPERATOR_IMAGE ) . > /dev/null 2>&1
460460 @$(CONTAINER_ENGINE ) tag $(OPERATOR_IMAGE ) localhost/$(OPERATOR_IMAGE ) 2> /dev/null || true
@@ -726,7 +726,7 @@ kind-down: ## Stop and delete kind cluster
726726 @cd e2e && KIND_CLUSTER_NAME=$(KIND_CLUSTER_NAME ) CONTAINER_ENGINE=$(CONTAINER_ENGINE ) ./scripts/cleanup.sh
727727 @echo " $( COLOR_GREEN) ✓$( COLOR_RESET) Kind cluster '$( KIND_CLUSTER_NAME) ' deleted"
728728
729- kind-port-forward : check-kubectl # # Port-forward kind services (for remote Podman)
729+ kind-port-forward : check-kubectl check-local-context # # Port-forward kind services (for remote Podman)
730730 @echo " $( COLOR_BOLD) Port forwarding kind services ($( KIND_CLUSTER_NAME) )$( COLOR_RESET) "
731731 @echo " "
732732 @echo " Frontend: http://localhost:$( KIND_FWD_FRONTEND_PORT) "
@@ -739,7 +739,7 @@ kind-port-forward: check-kubectl ## Port-forward kind services (for remote Podma
739739 (kubectl port-forward -n ambient-code svc/backend-service $( KIND_FWD_BACKEND_PORT) :8080 > /dev/null 2>&1 & ); \
740740 wait
741741
742- dev-bootstrap : check-kubectl # # Bootstrap developer workspace with API key and integrations
742+ dev-bootstrap : check-kubectl check-local-context # # Bootstrap developer workspace with API key and integrations
743743 @./scripts/bootstrap-workspace.sh
744744
745745# #@ E2E Testing (Portable)
@@ -770,7 +770,7 @@ test-e2e-setup: ## Install e2e test dependencies
770770
771771e2e-setup : test-e2e-setup # # Alias for test-e2e-setup (backward compatibility)
772772
773- kind-rebuild : check-kind check-kubectl build-all # # Rebuild, reload, and restart all components in kind
773+ kind-rebuild : check-kind check-kubectl check-local-context build-all # # Rebuild, reload, and restart all components in kind
774774 @$(if $(filter podman,$(CONTAINER_ENGINE ) ) ,KIND_EXPERIMENTAL_PROVIDER=podman) kind get clusters 2> /dev/null | grep -q ' ^$(KIND_CLUSTER_NAME)$$' || \
775775 (echo " $( COLOR_RED) ✗$( COLOR_RESET) Kind cluster '$( KIND_CLUSTER_NAME) ' not found. Run 'make kind-up LOCAL_IMAGES=true' first." && exit 1)
776776 @$(MAKE ) --no-print-directory _kind-load-images
@@ -848,6 +848,21 @@ check-kubectl: ## Check if kubectl is installed
848848 @command -v kubectl > /dev/null 2>&1 || \
849849 (echo " $( COLOR_RED) ✗$( COLOR_RESET) kubectl not found. Install: https://kubernetes.io/docs/tasks/tools/" && exit 1)
850850
851+ check-local-context : # # Verify kubectl context points to a local cluster (kind or minikube)
852+ ifneq ($(SKIP_CONTEXT_CHECK ) ,true)
853+ @ctx=$$(kubectl config current-context 2>/dev/null || echo ""); \
854+ if echo "$$ctx" | grep -qE '^(kind-|minikube$$)'; then \
855+ : ; \
856+ else \
857+ echo "$(COLOR_RED)✗$(COLOR_RESET) Current kubectl context '$$ctx' does not look like a local cluster."; \
858+ echo " Expected a context starting with 'kind-' or named 'minikube'."; \
859+ echo " Switch context first, e.g.: kubectl config use-context kind-ambient-local"; \
860+ echo ""; \
861+ echo " To bypass this check: make <target> SKIP_CONTEXT_CHECK=true"; \
862+ exit 1; \
863+ fi
864+ endif
865+
851866check-architecture : # # Validate build architecture matches host
852867 @echo " $( COLOR_BOLD) Architecture Check$( COLOR_RESET) "
853868 @echo " Host: $( HOST_OS) / $( HOST_ARCH) "
0 commit comments