Integrate k8s setup with SMO dependencies post-k8s installation 10/14910/3
authorBimo Fransiscus Asisi <d11002806@gapps.ntust.edu.tw>
Sun, 14 Sep 2025 10:54:51 +0000 (18:54 +0800)
committerBimo Fransiscus Asisi <d11002806@gapps.ntust.edu.tw>
Sun, 14 Sep 2025 11:38:19 +0000 (19:38 +0800)
Issue-Id: INT-198
Change-Id: I3a26c3b583561b264a035a292b4c99001323cd1b
Signed-off-by: Bimo Fransiscus Asisi <d11002806@gapps.ntust.edu.tw>
tools/setup_k8s/Makefile [new file with mode: 0644]
tools/setup_k8s/README.md [new file with mode: 0644]
tools/setup_k8s/scripts/setup_k8s.sh [moved from tools/setup_k8s/setup_k8s.sh with 91% similarity]

diff --git a/tools/setup_k8s/Makefile b/tools/setup_k8s/Makefile
new file mode 100644 (file)
index 0000000..2e31c05
--- /dev/null
@@ -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 (file)
index 0000000..24a97f3
--- /dev/null
@@ -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               
+````
similarity index 91%
rename from tools/setup_k8s/setup_k8s.sh
rename to tools/setup_k8s/scripts/setup_k8s.sh
index e89a3c0..3b274f7 100755 (executable)
 #   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)