Skip to content

Commit c240c95

Browse files
committed
fix: fix ns error
Signed-off-by: yuluo-yx <[email protected]>
1 parent 82323fb commit c240c95

File tree

2 files changed

+33
-14
lines changed

2 files changed

+33
-14
lines changed

tools/make/helm.mk

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ NC ?= \033[0m
2323
helm-uninstall helm-status helm-list helm-history helm-rollback helm-test \
2424
helm-package helm-dev helm-prod helm-values helm-manifest \
2525
helm-port-forward-api helm-port-forward-grpc helm-port-forward-metrics \
26-
helm-logs helm-clean helm-setup helm-cleanup help-helm
26+
helm-logs helm-clean helm-setup helm-cleanup help-helm _check-k8s
2727

2828
helm-lint: ## Lint the Helm chart
2929
helm-lint:
@@ -40,9 +40,14 @@ helm-template:
4040
--namespace $(HELM_NAMESPACE)
4141

4242
helm-install: ## Install the Helm chart
43-
helm-install:
43+
helm-install: _check-k8s
4444
@$(LOG_TARGET)
4545
@echo "Installing Helm release: $(HELM_RELEASE_NAME)"
46+
@if helm list -n $(HELM_NAMESPACE) 2>/dev/null | grep -q "^$(HELM_RELEASE_NAME)"; then \
47+
echo "$(YELLOW)[WARNING]$(NC) Release $(HELM_RELEASE_NAME) already exists in namespace $(HELM_NAMESPACE)"; \
48+
echo "$(BLUE)[INFO]$(NC) Use 'make helm-upgrade' to upgrade or 'make helm-uninstall' to remove it first"; \
49+
exit 1; \
50+
fi
4651
@helm install $(HELM_RELEASE_NAME) $(HELM_CHART_PATH) \
4752
$(if $(HELM_VALUES_FILE),-f $(HELM_VALUES_FILE)) \
4853
$(if $(HELM_SET_VALUES),--set $(HELM_SET_VALUES)) \
@@ -54,7 +59,7 @@ helm-install:
5459
@$(MAKE) helm-status
5560

5661
helm-upgrade: ## Upgrade the Helm release
57-
helm-upgrade:
62+
helm-upgrade: _check-k8s
5863
@$(LOG_TARGET)
5964
@echo "Upgrading Helm release: $(HELM_RELEASE_NAME)"
6065
@helm upgrade $(HELM_RELEASE_NAME) $(HELM_CHART_PATH) \
@@ -67,10 +72,12 @@ helm-upgrade:
6772
@$(MAKE) helm-status
6873

6974
helm-install-or-upgrade: ## Install or upgrade the Helm release (idempotent)
70-
helm-install-or-upgrade:
75+
helm-install-or-upgrade: _check-k8s
7176
@if helm list -n $(HELM_NAMESPACE) 2>/dev/null | grep -q "^$(HELM_RELEASE_NAME)"; then \
77+
echo "$(BLUE)[INFO]$(NC) Release exists, upgrading..."; \
7278
$(MAKE) helm-upgrade; \
7379
else \
80+
echo "$(BLUE)[INFO]$(NC) Release does not exist, installing..."; \
7481
$(MAKE) helm-install; \
7582
fi
7683

@@ -106,8 +113,13 @@ helm-rollback:
106113
@$(MAKE) helm-status
107114

108115
helm-test: ## Test the Helm release
109-
helm-test:
116+
helm-test: _check-k8s
110117
@$(LOG_TARGET)
118+
@if ! helm list -n $(HELM_NAMESPACE) 2>/dev/null | grep -q "^$(HELM_RELEASE_NAME)"; then \
119+
echo "$(RED)[ERROR]$(NC) Release $(HELM_RELEASE_NAME) not found in namespace $(HELM_NAMESPACE)"; \
120+
echo "$(BLUE)[INFO]$(NC) Please run 'make helm-install' or 'make helm-setup' first"; \
121+
exit 1; \
122+
fi
111123
@echo "$(BLUE)[INFO]$(NC) Checking deployment status..."
112124
@kubectl wait --for=condition=Available deployment/$(HELM_RELEASE_NAME) \
113125
-n $(HELM_NAMESPACE) --timeout=300s || echo "$(RED)[ERROR]$(NC) Deployment not ready"
@@ -196,4 +208,19 @@ helm-cleanup:
196208
@echo "$(GREEN)[SUCCESS]$(NC) Complete cleanup finished!"
197209

198210
helm-clean: ## Alias for helm-cleanup
199-
helm-clean: helm-cleanup # Rollback to previous"
211+
helm-clean: helm-cleanup
212+
213+
# Internal helper target to check if Kubernetes is available
214+
_check-k8s:
215+
@if ! kubectl cluster-info &>/dev/null; then \
216+
echo "$(RED)[ERROR]$(NC) Kubernetes cluster is not accessible"; \
217+
echo "$(BLUE)[INFO]$(NC) Please ensure your Kubernetes cluster is running:"; \
218+
echo " - For local development: minikube start / kind create cluster / docker desktop"; \
219+
echo " - For remote clusters: check your kubeconfig and cluster connection"; \
220+
echo ""; \
221+
echo "$(YELLOW)[TIP]$(NC) You can use the following commands to start a local cluster:"; \
222+
echo " - minikube: make kube-up"; \
223+
echo " - kind: make kind-cluster-create"; \
224+
exit 1; \
225+
fi
226+
@echo "$(GREEN)[✓]$(NC) Kubernetes cluster is accessible"

tools/make/linter.mk

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,6 @@
44

55
##@ Linter
66

7-
docs-lint: docs-install ## Lint documentation in website/
8-
@$(LOG_TARGET)
9-
cd website && npm run lint
10-
11-
docs-lint-fix: docs-install ## Auto-fix documentation lint issues in website/
12-
@$(LOG_TARGET)
13-
cd website && npm run lint:fix
14-
157
markdown-lint: ## Lint all markdown files in the project
168
@$(LOG_TARGET)
179
markdownlint -c tools/linter/markdown/markdownlint.yaml "**/*.md" \

0 commit comments

Comments
 (0)