@@ -66,7 +66,7 @@ case $PLATFORM in
6666 PLATFORM=" win32"
6767 ;;
6868 * )
69- err " unsupported platform: $PLATFORM "
69+ log_error " unsupported platform: $PLATFORM "
7070 ;;
7171esac
7272
@@ -100,21 +100,21 @@ check_cmd() {
100100# Run a command that should never fail. If the command fails execution
101101# will immediately terminate with an error showing the failing command.
102102ensure () {
103- if ! " $@ " ; then err " command failed: $* " ; fi
103+ if ! " $@ " ; then log_error " command failed: $* " ; fi
104104}
105105
106106# Downloads $1 into $2 or stdout
107107download () {
108108 if [ -n " $2 " ]; then
109109 # output into $2
110- if check_cmd curl; then
110+ if command_exists curl; then
111111 curl -#o " $2 " -L " $1 "
112112 else
113113 wget --show-progress -qO " $2 " " $1 "
114114 fi
115115 else
116116 # output to stdout
117- if check_cmd curl; then
117+ if command_exists curl; then
118118 curl -#L " $1 "
119119 else
120120 wget --show-progress -qO- " $1 "
@@ -217,16 +217,26 @@ install_helm() {
217217 log_info " Checking helm..."
218218
219219 # Fetch and extract the latest helm release version
220- LATEST_RELEASE=$( curl -s " https://api.github.com/repos/helm/helm/releases/latest" | grep ' "tag_name":' | sed -E ' s/.*"([^"]+)".*/\1/' )
220+ LATEST_RELEASE=$( curl -s " https://api.github.com/repos/helm/helm/releases/latest" 2> /dev/null | grep ' "tag_name":' | sed -E ' s/.*"([^"]+)".*/\1/' )
221+
222+ # Check if we got a version (network connectivity)
223+ if [[ -z " $LATEST_RELEASE " ]]; then
224+ log_warn " Unable to fetch latest helm version. Network may be unavailable."
225+ if command_exists helm; then
226+ log_info " helm is already installed. Skipping update check. Version installed: $( helm version --short 2> /dev/null || echo ' unknown' ) "
227+ return
228+ else
229+ log_error " helm is not installed and unable to fetch latest version. Please check your internet connection."
230+ fi
231+ fi
221232
222- # Output the latest release
223233 log_info " Latest helm version available: $LATEST_RELEASE "
224234
225- # Check if kubectl is already installed
235+ # Check if helm is already installed
226236 if command_exists helm; then
227- log_info " helm is already installed. Version installed: $( helm version --short) "
237+ log_info " helm is already installed. Version installed: $( helm version --short 2> /dev/null || echo ' unknown ' ) "
228238 else
229- log_info " helm in not installed."
239+ log_info " helm is not installed."
230240 log_info " Installing helm..."
231241 # Download the latest release
232242 ensure curl -sSL -O " https://get.helm.sh/helm-$LATEST_RELEASE -$PLATFORM -$ARCHITECTURE .tar.gz"
@@ -244,7 +254,6 @@ install_helm() {
244254
245255 log_info " helm installed successfully."
246256 fi
247-
248257}
249258
250259# Install or update Kind
@@ -259,6 +268,92 @@ install_kind() {
259268 log_info " Kind $KIND_VERSION is installed."
260269}
261270
271+ # Install or update k9s
272+ install_k9s () {
273+ log_info " Checking k9s..."
274+
275+ # Fetch and extract the latest k9s release version
276+ log_info " Fetching latest k9s version from GitHub API..."
277+ LATEST_K9S_VERSION=$( curl -s " https://api.github.com/repos/derailed/k9s/releases/latest" 2> /dev/null | grep ' "tag_name":' | sed -E ' s/.*"([^"]+)".*/\1/' )
278+
279+ # Check if we got a version (network connectivity)
280+ if [[ -z " $LATEST_K9S_VERSION " ]]; then
281+ log_warn " Unable to fetch latest k9s version. Network may be unavailable."
282+ if command_exists k9s; then
283+ log_info " k9s is already installed. Skipping update check."
284+ return
285+ else
286+ log_error " k9s is not installed and unable to fetch latest version. Please check your internet connection."
287+ fi
288+ fi
289+
290+ log_info " Latest k9s version available: $LATEST_K9S_VERSION "
291+
292+ # Check if k9s is already installed
293+ if command_exists k9s; then
294+ # Extract version number (k9s doesn't use 'v' prefix in version output)
295+ INSTALLED_VERSION=$( k9s version --short 2> /dev/null | head -n1 | awk ' {print $2}' )
296+ if [[ -n " $INSTALLED_VERSION " ]]; then
297+ # Add 'v' prefix to match release format
298+ INSTALLED_VERSION=" v$INSTALLED_VERSION "
299+ log_info " k9s is already installed. Version installed: $INSTALLED_VERSION ."
300+ if [[ " $INSTALLED_VERSION " == " $LATEST_K9S_VERSION " ]]; then
301+ log_info " k9s is up to date."
302+ return
303+ else
304+ # Check if the k9s version is installed as we expect
305+ local k9s_path=$( which k9s)
306+ if [[ " $k9s_path " != " /usr/local/bin/k9s" ]]; then
307+
308+ log_info " k9s is installed at $k9s_path meaning it is managed by a package manager."
309+ log_info " If you want the latest version, consider updating k9s through your package manager."
310+ return
311+ fi
312+ fi
313+ else
314+ log_warn " k9s is installed but version could not be determined."
315+ fi
316+ fi
317+
318+ log_info " Installing k9s $LATEST_K9S_VERSION ..."
319+
320+ # Download the latest release
321+ # k9s uses capital case for platform names (Linux, Darwin)
322+ if [[ " $PLATFORM " == " linux" ]]; then
323+ K9S_PLATFORM=" Linux"
324+ elif [[ " $PLATFORM " == " darwin" ]]; then
325+ K9S_PLATFORM=" Darwin"
326+ else
327+ log_error " Unsupported platform for k9s: $PLATFORM "
328+ fi
329+
330+ K9S_FILENAME=" k9s_${K9S_PLATFORM} _${ARCHITECTURE} .tar.gz"
331+ K9S_URL=" https://github.com/derailed/k9s/releases/download/$LATEST_K9S_VERSION /$K9S_FILENAME "
332+
333+ log_info " Downloading k9s from: $K9S_URL "
334+ if ! curl -sSL -O " $K9S_URL " ; then
335+ log_error " Failed to download k9s from $K9S_URL . Please check the URL and your internet connection."
336+ fi
337+
338+ # Extract and install
339+ log_info " Extracting and installing k9s..."
340+ if ! tar -xzf " $K9S_FILENAME " 2> /dev/null; then
341+ log_error " Failed to extract $K9S_FILENAME . The download may be corrupted."
342+ fi
343+
344+ if [[ ! -f " k9s" ]]; then
345+ log_error " k9s binary not found after extraction. Archive contents may be unexpected."
346+ fi
347+
348+ ensure chmod +x k9s
349+ ensure sudo mv k9s /usr/local/bin/
350+
351+ # Clean up
352+ rm -f " $K9S_FILENAME " README.md LICENSE
353+
354+ log_info " k9s $LATEST_K9S_VERSION installed successfully."
355+ }
356+
262357# Install or update obol CLI
263358install_obol_cli () {
264359 log_info " Checking obol CLI..."
@@ -402,10 +497,10 @@ launch_stack() {
402497 log_info " Installing the Obol Stack Ethereum light client configured for $__network ..."
403498 ensure helm upgrade --namespace l1 --create-namespace --hide-notes --force --install l1-light-client obol/helios -f ../values/$__network /helios.yaml
404499
405- # If mode="full", also sync an Erigon full node
500+ # If mode="full", also sync a full node
406501 if [[ " $__mode " = " full" ]]; then
407- log_info " Installing an Ethereum Erigon full node client..."
408- ensure helm upgrade --namespace l1 --create-namespace --install l1-erigon ethereum/erigon -f ../values/mainnet/erigon .yaml -f ../values/ $__network /erigon.yaml
502+ log_info " Installing an Ethereum full node client synced to $__network ..."
503+ ensure helm upgrade --install -- namespace l1 --create-namespace l1-full-node ethereum/ethereum-node -f ../values/ethereum-node .yaml --set global.main.network= $__network
409504 fi
410505
411506 log_info " Installing the Obol Stack Ethereum eRPC load balancer..."
@@ -467,10 +562,6 @@ launch_stack() {
467562 ensure helm upgrade --hide-notes --namespace monitoring --create-namespace --install monitoring prometheus-community/kube-prometheus-stack -f ../values/kube-prometheus-stack.yaml --set grafana.ingress.enabled=false --set alertmanager.ingress.enabled=false
468563 fi
469564
470- # Todo(Oisin): EthpandaOps/ethereum-node not flexible enough just yet, installing clients directly with their dedicated chart
471- # ensure helm upgrade --namespace l1 --create-namespace --install --set erigon.enabled=true l1-erigon ethereum/ethereum-node
472- # Todo(Oisin): Blockscout segfaulting, unclear why
473- # ensure obol install ethereum/blockscout --values ./values/blockscout.yaml
474565 }
475566
476567# Main logic
@@ -524,6 +615,8 @@ main() {
524615 install_kubectl
525616 install_kind
526617 install_helm
618+ install_k9s
619+
527620 # install_obol_cli
528621 # check_obolup_update
529622 if [[ " $clean " -ne 0 ]]; then
0 commit comments