From 6a927675ee11b99c0b17783c70700b58f72741fa Mon Sep 17 00:00:00 2001 From: Bimo Fransiscus Asisi Date: Sun, 14 Sep 2025 18:54:51 +0800 Subject: [PATCH] Integrate k8s setup with SMO dependencies post-k8s installation Issue-Id: INT-198 Change-Id: I3a26c3b583561b264a035a292b4c99001323cd1b Signed-off-by: Bimo Fransiscus Asisi --- tools/setup_k8s/Makefile | 38 ++++++++++++++++++++++++++++++ tools/setup_k8s/README.md | 11 +++++++++ tools/setup_k8s/{ => scripts}/setup_k8s.sh | 24 ------------------- 3 files changed, 49 insertions(+), 24 deletions(-) create mode 100644 tools/setup_k8s/Makefile create mode 100644 tools/setup_k8s/README.md rename tools/setup_k8s/{ => scripts}/setup_k8s.sh (91%) diff --git a/tools/setup_k8s/Makefile b/tools/setup_k8s/Makefile new file mode 100644 index 00000000..2e31c05b --- /dev/null +++ b/tools/setup_k8s/Makefile @@ -0,0 +1,38 @@ +SHELL := /bin/bash +.SHELLFLAGS := -eu -o pipefail -c +.DEFAULT_GOAL := help +.NOTPARALLEL: + +SCRIPTS_DIR := scripts +SUDO ?= +KUBECONFIG ?= $(HOME)/.kube/config +export KUBECONFIG + +.PHONY: help k8s storage chartmuseum all run + +help: + @grep -E '^[a-zA-Z0-9_-]+:.*?## ' Makefile | \ + awk 'BEGIN {FS=":.*?## "}; {printf " \033[36m%-14s\033[0m %s\n", $$1, $$2}' + +k8s: ## Install k8s with CNI (requires IP=...) + @test -n "$(IP)" || { echo "Error: IP is required. Usage: make k8s IP=192.168.8.10"; exit 1; } + @$(SUDO) bash "$(SCRIPTS_DIR)/setup_k8s.sh" --ip-address "$(IP)" \ + || { code=$$?; echo "k8s failed (setup_k8s.sh exit $$code)"; exit $$code; } + @echo "<== k8s: done" + +storage: ## Install local storage class (OpenEBS) + @echo "==> storage: using KUBECONFIG=$(KUBECONFIG)" + @env KUBECONFIG="$(KUBECONFIG)" HOME="$(HOME)" \ + bash "$(SCRIPTS_DIR)/openebs.sh" \ + || { code=$$?; echo "storage failed (openebs.sh exit $$code)"; exit $$code; } + @echo "<== storage: done" + +chartmuseum: ## Install ChartMuseum + @echo "==> chartmuseum: using KUBECONFIG=$(KUBECONFIG)" + @env KUBECONFIG="$(KUBECONFIG)" HOME="$(HOME)" \ + bash "$(SCRIPTS_DIR)/chartmuseum.sh" \ + || { code=$$?; echo "chartmuseum failed (chartmuseum.sh exit $$code)"; exit $$code; } + @echo "<== chartmuseum: done" + +all: k8s storage chartmuseum +run: all \ No newline at end of file diff --git a/tools/setup_k8s/README.md b/tools/setup_k8s/README.md new file mode 100644 index 00000000..24a97f3e --- /dev/null +++ b/tools/setup_k8s/README.md @@ -0,0 +1,11 @@ + + +```` +setup_k8s/ +├── Makefile +├── scripts/ +│ ├── setup_k8s.sh # Install k8s, CNI. +│ ├── openebs.sh # Install OpenEBS local storage class +│ └── chartmuseum.sh # Install Chartmuseum + plugins +└── README.md +```` diff --git a/tools/setup_k8s/setup_k8s.sh b/tools/setup_k8s/scripts/setup_k8s.sh similarity index 91% rename from tools/setup_k8s/setup_k8s.sh rename to tools/setup_k8s/scripts/setup_k8s.sh index e89a3c08..3b274f76 100755 --- a/tools/setup_k8s/setup_k8s.sh +++ b/tools/setup_k8s/scripts/setup_k8s.sh @@ -15,30 +15,6 @@ # limitations under the License. # ################################################################################ -# Function to be executed on script exit or interruption -cleanup() { - echo "" # Add a newline for cleaner output after Ctrl+C - echo "Caught Ctrl+C or script exiting. Performing cleanup..." - # Add any specific cleanup tasks here that you want to happen - # For example: - # rm -f /tmp/my_temp_file - # killall -SIGTERM any_background_processes_started_by_script - - echo "Cleanup complete. Exiting." - exit 1 # Exit with a non-zero status to indicate abnormal termination -} - -# Trap SIGINT (Ctrl+C) to call the cleanup function -trap cleanup SIGINT - -# Trap EXIT to also call the cleanup function (useful for general cleanup) -# If you want cleanup to *always* happen, regardless of how the script ends, -# use EXIT. If you only want it on Ctrl+C, remove this line. -# Note: If you trap both SIGINT and EXIT, be careful with logic to avoid -# double-cleanup if SIGINT also causes an EXIT. A common pattern is to -# have SIGINT *call* EXIT after its specific actions. -trap cleanup EXIT - # Capture start time start_time=$(date +%s) -- 2.16.6