Skip to content

Commit 0cb28cb

Browse files
feat: implement dual-mode execution for scripts and enhance Makefile structure
1 parent aadff74 commit 0cb28cb

File tree

12 files changed

+349
-52
lines changed

12 files changed

+349
-52
lines changed

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ WORKER_IP ?=
1616
KUBECONFIG_CONTEXT ?= k3s-lab
1717
K3S_VERSION ?= v1.32.2+k3s1
1818

19-
# Root of this repo (works whether used standalone or as a submodule)
20-
K3S_LAB := $(abspath $(dir $(MAKEFILE_LIST)))
19+
# Root of this repo — used by run-local-script / run-remote-script in local mode
20+
K3S_LAB := $(abspath $(dir $(MAKEFILE_LIST)))
21+
K3S_LAB_RAW := https://raw.githubusercontent.com/KevinDeBenedetti/k3s-lab/main
2122

2223
# Terminal colors
2324
GREEN := \033[0;32m
@@ -26,7 +27,9 @@ CYAN := \033[0;36m
2627
RED := \033[0;31m
2728
RESET := \033[0m
2829

30+
include makefiles/00-lib.mk
2931
include makefiles/10-help.mk
32+
include makefiles/20-vps.mk
3033
include makefiles/30-k3s.mk
3134
include makefiles/40-kubeconfig.mk
3235
include makefiles/50-deploy.mk

docs/.vitepressrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"title": "K3s-lab",
2+
"title": "k3s-lab",
33
"description": "Production-ready k3s cluster on VPS — automated setup with Traefik, cert-manager, Prometheus, Grafana, Loki, and Promtail.",
44
"icon": "☸️",
55
"order": 5,

lib/run-mode.sh

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# lib/run-mode.sh — Dual-mode execution preamble for k3s-lab scripts.
2+
#
3+
# Source this file at the very top of any script (after set -euo pipefail):
4+
#
5+
# K3S_LAB_RAW="${K3S_LAB_RAW:-https://raw.githubusercontent.com/KevinDeBenedetti/k3s-lab/main}"
6+
# # shellcheck source=lib/run-mode.sh
7+
# source "$(dirname "${BASH_SOURCE[0]:-run-mode.sh}")/../lib/run-mode.sh"
8+
#
9+
# Why this exists
10+
# ───────────────
11+
# Scripts can be executed in two ways:
12+
# LOCAL — `bash /path/to/script.sh` (BASH_SOURCE[0] is a real file)
13+
# REMOTE — `bash <(curl -fsSL ...)` (BASH_SOURCE[0] is /dev/fd/NN — a pipe)
14+
#
15+
# In remote mode the usual "cd $(dirname ${BASH_SOURCE[0]})" trick fails because
16+
# /dev/fd/NN is not a directory. This preamble detects the mode and exposes
17+
# three helper functions that transparently resolve paths in either case.
18+
#
19+
# Exposed helpers
20+
# ───────────────
21+
# _lib <name> Source a file from lib/ (e.g. _lib log.sh)
22+
# _k8s <rel-path> Echo an absolute path or URL to a kubernetes/ manifest
23+
# (safe to pass to `kubectl apply -f`)
24+
# _helm_val <rel-path> Echo a local path to a helm values file; in remote
25+
# mode the file is downloaded to a temp path first.
26+
# Temp files are cleaned up automatically on EXIT.
27+
#
28+
# Prerequisites
29+
# ─────────────
30+
# K3S_LAB_RAW must be set before sourcing this file (or it defaults to main).
31+
# ──────────────────────────────────────────────────────────────────────────────
32+
33+
K3S_LAB_RAW="${K3S_LAB_RAW:-https://raw.githubusercontent.com/KevinDeBenedetti/k3s-lab/main}"
34+
35+
# Detect execution context.
36+
_run_src="${BASH_SOURCE[1]:-}" # [1] = the script that sourced us
37+
if [[ -n "${_run_src}" && "${_run_src}" != /dev/fd/* && -f "${_run_src}" ]]; then
38+
_RUN_REPO="$(cd "$(dirname "${_run_src}")/.." && pwd)"
39+
_RUN_REMOTE=0
40+
else
41+
# Could also be triggered when K3S_LAB is explicitly empty (remote mode).
42+
_RUN_REPO=""
43+
_RUN_REMOTE=1
44+
fi
45+
46+
# Also allow K3S_LAB env var to override — set by the local-mode Make macro.
47+
if [[ -n "${K3S_LAB:-}" ]]; then
48+
_RUN_REPO="${K3S_LAB}"
49+
_RUN_REMOTE=0
50+
fi
51+
52+
# _lib <name>
53+
# Source a helper from lib/. Local: from disk. Remote: streamed via curl.
54+
_lib() {
55+
local name="$1"
56+
if [[ "${_RUN_REMOTE}" -eq 0 ]]; then
57+
# shellcheck disable=SC1090
58+
source "${_RUN_REPO}/lib/${name}"
59+
else
60+
# shellcheck disable=SC1090
61+
source <(curl -fsSL "${K3S_LAB_RAW}/lib/${name}")
62+
fi
63+
}
64+
65+
# _k8s <rel-path>
66+
# Return the path (or URL) to a kubernetes/ manifest.
67+
# Local: absolute filesystem path → kubectl apply -f, helm --values, etc.
68+
# Remote: raw GitHub URL → kubectl apply -f supports URLs natively.
69+
_k8s() {
70+
if [[ "${_RUN_REMOTE}" -eq 0 ]]; then
71+
echo "${_RUN_REPO}/kubernetes/$1"
72+
else
73+
echo "${K3S_LAB_RAW}/kubernetes/$1"
74+
fi
75+
}
76+
77+
# _k8s_file <rel-path>
78+
# Return a local filesystem path to any kubernetes/ file.
79+
# Local: absolute filesystem path (no download needed).
80+
# Remote: download to a temp file and return its path.
81+
# All temp files are registered for cleanup on EXIT.
82+
#
83+
# Use this (not _k8s) when you need a real file on disk:
84+
# helm upgrade --values "$(_k8s_file ingress/traefik-values.yaml)"
85+
# envsubst < "$(_k8s_file cert-manager/clusterissuer.yaml)" | kubectl apply -f -
86+
_run_tmp_files=()
87+
_k8s_file() {
88+
if [[ "${_RUN_REMOTE}" -eq 0 ]]; then
89+
echo "${_RUN_REPO}/kubernetes/$1"
90+
else
91+
local tmpf
92+
tmpf="$(mktemp /tmp/k8s-file-XXXXXXXX.yaml)"
93+
_run_tmp_files+=("${tmpf}")
94+
curl -fsSL "${K3S_LAB_RAW}/kubernetes/$1" -o "${tmpf}"
95+
echo "${tmpf}"
96+
fi
97+
}
98+
99+
# Register cleanup of any temp files created by _helm_val.
100+
_run_mode_cleanup() {
101+
[[ "${#_run_tmp_files[@]}" -gt 0 ]] && rm -f "${_run_tmp_files[@]}" 2>/dev/null || true
102+
}
103+
trap _run_mode_cleanup EXIT

makefiles/00-lib.mk

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Module: makefiles/00-lib.mk
2+
# ──────────────────────────────────────────────────────────────────────────────
3+
# Dual-mode script execution helpers
4+
#
5+
# k3s-lab can be used in two ways:
6+
# LOCAL — clone the repo; K3S_LAB := $(PWD) is set in the root Makefile.
7+
# Scripts are scp'd to remote hosts or run directly from disk.
8+
# REMOTE — infra fetches this .mk file via curl; K3S_LAB is empty.
9+
# Scripts are fetched on-demand from K3S_LAB_RAW (GitHub raw).
10+
#
11+
# Macros (use with $(call ...)):
12+
# run-remote-script(rel-path, host, env-prefix)
13+
# Run a script on a remote SSH host.
14+
# rel-path — path relative to k3s-lab root, e.g. k3s/install-master.sh
15+
# host — target hostname/IP
16+
# env-prefix — space-separated VAR=value pairs prepended to the command
17+
#
18+
# run-local-script(rel-path, args...)
19+
# Run a script on the local machine.
20+
# rel-path — path relative to k3s-lab root, e.g. scripts/get-kubeconfig.sh
21+
# args — positional arguments forwarded to the script
22+
# ──────────────────────────────────────────────────────────────────────────────
23+
24+
ifdef K3S_LAB
25+
26+
# ── Local mode: K3S_LAB points to the cloned repo ────────────────────────────
27+
28+
# scp the script to /tmp on the remote host, execute with env-prefix, then clean up.
29+
define run-remote-script
30+
scp -i $(SSH_KEY) -P $(SSH_PORT) \
31+
$(K3S_LAB)/$(1) $(SSH_USER)@$(2):/tmp/$(notdir $(1)) && \
32+
ssh -i $(SSH_KEY) -p $(SSH_PORT) $(SSH_USER)@$(2) \
33+
"$(3) bash /tmp/$(notdir $(1)) && rm -f /tmp/$(notdir $(1))"
34+
endef
35+
36+
# Run a local script directly from the repo checkout.
37+
define run-local-script
38+
K3S_LAB=$(K3S_LAB) K3S_LAB_RAW=$(K3S_LAB_RAW) \
39+
SSH_KEY=$(SSH_KEY) SSH_PORT=$(SSH_PORT) \
40+
bash $(K3S_LAB)/$(1) $(2)
41+
endef
42+
43+
else
44+
45+
# ── Remote mode: K3S_LAB is empty — fetch scripts via curl ───────────────────
46+
47+
# Stream the script from GitHub raw into the remote host's bash via SSH.
48+
define run-remote-script
49+
ssh -i $(SSH_KEY) -p $(SSH_PORT) $(SSH_USER)@$(2) \
50+
"curl -fsSL $(K3S_LAB_RAW)/$(1) | $(3) bash"
51+
endef
52+
53+
# Fetch and run the script locally via process substitution.
54+
# K3S_LAB_RAW is exported so the script can source its lib/ helpers remotely.
55+
define run-local-script
56+
K3S_LAB= K3S_LAB_RAW=$(K3S_LAB_RAW) \
57+
SSH_KEY=$(SSH_KEY) SSH_PORT=$(SSH_PORT) \
58+
bash <(curl -fsSL $(K3S_LAB_RAW)/$(1)) $(2)
59+
endef
60+
61+
endif

makefiles/20-vps.mk

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Module: makefiles/20-vps.mk
2+
# ──────────────────────────────────────────────────────────────────────────────
3+
# VPS Bootstrap — runs dotfiles setup on a fresh Debian VPS
4+
# Uses run-local-script from 00-lib.mk (local bash or remote curl, transparent).
5+
# ──────────────────────────────────────────────────────────────────────────────
6+
7+
.PHONY: setup-master setup-worker setup-all
8+
9+
setup-master: ## Bootstrap master VPS with dotfiles (requires MASTER_IP)
10+
@[ -n "$(MASTER_IP)" ] || (echo "$(RED)❌ MASTER_IP is not set — add it to .env$(RESET)"; exit 1)
11+
@echo "$(YELLOW)→ Setting up master VPS $(MASTER_IP) as $(INITIAL_USER)...$(RESET)"
12+
@$(call run-local-script,scripts/setup-vps.sh,$(MASTER_IP) $(SSH_USER) $(SSH_PORT) $(INITIAL_USER))
13+
14+
setup-worker: ## Bootstrap worker VPS with dotfiles (requires WORKER_IP)
15+
@[ -n "$(WORKER_IP)" ] || (echo "$(RED)❌ WORKER_IP is not set — add it to .env$(RESET)"; exit 1)
16+
@echo "$(YELLOW)→ Setting up worker VPS $(WORKER_IP) as $(INITIAL_USER)...$(RESET)"
17+
@$(call run-local-script,scripts/setup-vps.sh,$(WORKER_IP) $(SSH_USER) $(SSH_PORT) $(INITIAL_USER))
18+
19+
setup-all: setup-master setup-worker ## Bootstrap both VPS nodes with dotfiles

makefiles/30-k3s.mk

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
# Module: makefiles/30-k3s.mk (k3s-lab)
1+
# Module: makefiles/30-k3s.mk
22
# ──────────────────────────────────────────────────────────────────────────────
33
# k3s Installation
4+
# Uses run-remote-script from 00-lib.mk (local scp or remote curl, transparent).
45
# ──────────────────────────────────────────────────────────────────────────────
56

67
.PHONY: k3s-master k3s-worker k3s-open-master-firewall k3s-uninstall-master k3s-uninstall-worker
78

89
k3s-master: ## Install k3s server on master (requires MASTER_IP)
910
@[ -n "$(MASTER_IP)" ] || (echo "$(RED)❌ MASTER_IP is not set$(RESET)"; exit 1)
1011
@echo "$(YELLOW)→ Installing k3s master on $(MASTER_IP)...$(RESET)"
11-
@scp -i $(SSH_KEY) -P $(SSH_PORT) $(K3S_LAB)/k3s/install-master.sh $(SSH_USER)@$(MASTER_IP):/tmp/k3s-install-master.sh
12-
@ssh -i $(SSH_KEY) -p $(SSH_PORT) $(SSH_USER)@$(MASTER_IP) \
13-
"sudo K3S_VERSION=$(K3S_VERSION) PUBLIC_IP=$(MASTER_IP) WORKER_IP=$(WORKER_IP) bash /tmp/k3s-install-master.sh \
14-
&& rm -f /tmp/k3s-install-master.sh"
12+
@$(call run-remote-script,k3s/install-master.sh,$(MASTER_IP),sudo K3S_VERSION=$(K3S_VERSION) PUBLIC_IP=$(MASTER_IP) WORKER_IP=$(WORKER_IP))
1513
@echo "$(GREEN)✅ k3s master installed$(RESET)"
1614
@echo "$(YELLOW)→ Fetching node token and saving to .env...$(RESET)"
1715
@TOKEN=$$(ssh -i $(SSH_KEY) -p $(SSH_PORT) $(SSH_USER)@$(MASTER_IP) \
@@ -30,10 +28,7 @@ k3s-worker: ## Install k3s agent on worker (requires WORKER_IP, MASTER_IP, K3S_N
3028
@echo "$(YELLOW)→ Opening master firewall for new worker $(WORKER_IP)...$(RESET)"
3129
@$(MAKE) k3s-open-master-firewall WORKER_IP=$(WORKER_IP)
3230
@echo "$(YELLOW)→ Installing k3s worker on $(WORKER_IP)...$(RESET)"
33-
@scp -i $(SSH_KEY) -P $(SSH_PORT) $(K3S_LAB)/k3s/install-worker.sh $(SSH_USER)@$(WORKER_IP):/tmp/k3s-install-worker.sh
34-
@ssh -i $(SSH_KEY) -p $(SSH_PORT) $(SSH_USER)@$(WORKER_IP) \
35-
"sudo K3S_VERSION=$(K3S_VERSION) MASTER_IP=$(MASTER_IP) K3S_NODE_TOKEN=$(K3S_NODE_TOKEN) bash /tmp/k3s-install-worker.sh \
36-
&& rm -f /tmp/k3s-install-worker.sh"
31+
@$(call run-remote-script,k3s/install-worker.sh,$(WORKER_IP),sudo K3S_VERSION=$(K3S_VERSION) MASTER_IP=$(MASTER_IP) K3S_NODE_TOKEN=$(K3S_NODE_TOKEN))
3732
@echo "$(GREEN)✅ k3s worker installed$(RESET)"
3833

3934
k3s-open-master-firewall: ## Open master UFW for a new worker (requires WORKER_IP, MASTER_IP)
@@ -49,13 +44,9 @@ k3s-open-master-firewall: ## Open master UFW for a new worker (requires WORKER_I
4944
k3s-uninstall-master: ## Remove k3s from master (DESTRUCTIVE)
5045
@[ -n "$(MASTER_IP)" ] || (echo "$(RED)❌ MASTER_IP is not set$(RESET)"; exit 1)
5146
@echo "$(RED)⚠️ Removing k3s from master $(MASTER_IP)...$(RESET)"
52-
@scp -i $(SSH_KEY) -P $(SSH_PORT) $(K3S_LAB)/k3s/uninstall.sh $(SSH_USER)@$(MASTER_IP):/tmp/k3s-uninstall.sh
53-
@ssh -i $(SSH_KEY) -p $(SSH_PORT) $(SSH_USER)@$(MASTER_IP) \
54-
"sudo bash /tmp/k3s-uninstall.sh && rm -f /tmp/k3s-uninstall.sh"
47+
@$(call run-remote-script,k3s/uninstall.sh,$(MASTER_IP),sudo)
5548

5649
k3s-uninstall-worker: ## Remove k3s from worker (DESTRUCTIVE)
5750
@[ -n "$(WORKER_IP)" ] || (echo "$(RED)❌ WORKER_IP is not set$(RESET)"; exit 1)
5851
@echo "$(RED)⚠️ Removing k3s from worker $(WORKER_IP)...$(RESET)"
59-
@scp -i $(SSH_KEY) -P $(SSH_PORT) $(K3S_LAB)/k3s/uninstall.sh $(SSH_USER)@$(WORKER_IP):/tmp/k3s-uninstall.sh
60-
@ssh -i $(SSH_KEY) -p $(SSH_PORT) $(SSH_USER)@$(WORKER_IP) \
61-
"sudo bash /tmp/k3s-uninstall.sh && rm -f /tmp/k3s-uninstall.sh"
52+
@$(call run-remote-script,k3s/uninstall.sh,$(WORKER_IP),sudo)

makefiles/40-kubeconfig.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
# Module: makefiles/40-kubeconfig.mk
22
# ──────────────────────────────────────────────────────────────────────────────
33
# Kubeconfig
4+
# Uses run-local-script from 00-lib.mk (local bash or remote curl, transparent).
45
# ──────────────────────────────────────────────────────────────────────────────
56

67
.PHONY: kubeconfig
78

89
kubeconfig: ## Fetch kubeconfig from master and merge into ~/.kube/config
910
@[ -n "$(MASTER_IP)" ] || (echo "$(RED)❌ MASTER_IP is not set$(RESET)"; exit 1)
1011
@echo "$(YELLOW)→ Fetching kubeconfig from $(MASTER_IP)...$(RESET)"
11-
@SSH_KEY=$(SSH_KEY) SSH_PORT=$(SSH_PORT) bash $(K3S_LAB)/scripts/get-kubeconfig.sh $(MASTER_IP) $(SSH_USER) $(KUBECONFIG_CONTEXT)
12+
@$(call run-local-script,scripts/get-kubeconfig.sh,$(MASTER_IP) $(SSH_USER) $(KUBECONFIG_CONTEXT))
1213
@echo "$(GREEN)✅ Context '$(KUBECONFIG_CONTEXT)' ready$(RESET)"
1314
@echo " kubectl config use-context $(KUBECONFIG_CONTEXT)"

makefiles/50-deploy.mk

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
# Module: makefiles/50-deploy.mk
22
# ──────────────────────────────────────────────────────────────────────────────
33
# Stack Deployment
4+
# Uses run-local-script from 00-lib.mk (local bash or remote curl, transparent).
45
# ──────────────────────────────────────────────────────────────────────────────
56

67
.PHONY: deploy deploy-dashboard-secret deploy-monitoring deploy-grafana-secret deploy-logging
78

89
deploy: ## Deploy base stack (Traefik, cert-manager, ClusterIssuers)
910
@echo "$(YELLOW)→ Deploying base stack on $(shell kubectl config current-context 2>/dev/null)...$(RESET)"
10-
@bash $(K3S_LAB)/scripts/deploy-stack.sh
11+
@$(call run-local-script,scripts/deploy-stack.sh)
1112
@echo "$(GREEN)✅ Stack deployed$(RESET)"
1213

1314
deploy-dashboard-secret: ## Create Traefik dashboard BasicAuth secret (requires DASHBOARD_PASSWORD)
@@ -23,15 +24,15 @@ deploy-monitoring: ## Deploy observability stack (Prometheus + Grafana + Loki +
2324
@[ -n "$(GRAFANA_DOMAIN)" ] || (echo "$(RED)❌ GRAFANA_DOMAIN not set — add to .env$(RESET)"; exit 1)
2425
@[ -n "$(GRAFANA_PASSWORD)" ] || (echo "$(RED)❌ GRAFANA_PASSWORD not set — run make deploy-grafana-secret first$(RESET)"; exit 1)
2526
@echo "$(YELLOW)→ Deploying observability stack...$(RESET)"
26-
@bash $(K3S_LAB)/scripts/deploy-monitoring.sh
27+
@$(call run-local-script,scripts/deploy-monitoring.sh)
2728
@echo "$(YELLOW)→ Syncing Grafana admin password (grafana-cli reset)...$(RESET)"
2829
@kubectl --context $(KUBECONFIG_CONTEXT) exec -n monitoring deployment/kube-prometheus-stack-grafana \
2930
-- grafana-cli admin reset-admin-password "$(GRAFANA_PASSWORD)"
3031
@echo "$(GREEN)✅ Observability stack deployed$(RESET)"
3132

3233
deploy-logging: ## Deploy centralized logs stack (Loki + Promtail + Grafana dashboard)
3334
@echo "$(YELLOW)→ Deploying centralized logging stack...$(RESET)"
34-
@bash $(K3S_LAB)/scripts/deploy-monitoring.sh
35+
@$(call run-local-script,scripts/deploy-monitoring.sh)
3536
@echo "$(GREEN)✅ Centralized logging deployed$(RESET)"
3637

3738
deploy-grafana-secret: ## Create Grafana admin secret (requires GRAFANA_PASSWORD)

scripts/deploy-monitoring.sh

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,20 @@ set -euo pipefail
1414
# - Grafana IngressRoute + TLS certificate
1515
# =============================================================================
1616

17-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
18-
INFRA_ROOT="$(dirname "${SCRIPT_DIR}")"
17+
K3S_LAB_RAW="${K3S_LAB_RAW:-https://raw.githubusercontent.com/KevinDeBenedetti/k3s-lab/main}"
18+
19+
_run_src="${BASH_SOURCE[0]:-}"
20+
if [[ -n "${_run_src}" && "${_run_src}" != /dev/fd/* && -f "${_run_src}" ]]; then
21+
source "$(cd "$(dirname "${_run_src}")" && pwd)/../lib/run-mode.sh"
22+
else
23+
# shellcheck source=/dev/null
24+
source <(curl -fsSL "${K3S_LAB_RAW}/lib/run-mode.sh")
25+
fi
1926

20-
# --- Shared helpers ---
21-
source "${SCRIPT_DIR}/../lib/log.sh"
22-
source "${SCRIPT_DIR}/../lib/load-env.sh"
27+
_lib log.sh
28+
_lib load-env.sh
2329

24-
# --- Load .env — only sets variables not already in the environment ---
25-
# This lets Makefile targets override .env values at call time.
26-
load_env "${INFRA_ROOT}/.env"
30+
load_env "${_RUN_REPO:-.}/.env"
2731

2832
# --- Context (overridable via env for Lima / alternate clusters) ---
2933
KUBECONFIG_CONTEXT="${KUBECONFIG_CONTEXT:-k3s-infra}"
@@ -65,7 +69,7 @@ helm upgrade --install kube-prometheus-stack prometheus-community/kube-prometheu
6569
--version "${KUBE_PROMETHEUS_VERSION}" \
6670
--namespace monitoring \
6771
--create-namespace \
68-
--values "${INFRA_ROOT}/kubernetes/monitoring/kube-prometheus-values.yaml" \
72+
--values "$(_k8s_file monitoring/kube-prometheus-values.yaml)" \
6973
--set "grafana.grafana\.ini.server.root_url=https://${GRAFANA_DOMAIN}" \
7074
--wait \
7175
--timeout 600s
@@ -82,7 +86,7 @@ helm upgrade --install loki grafana/loki \
8286
--version "${LOKI_VERSION}" \
8387
--namespace monitoring \
8488
--create-namespace \
85-
--values "${INFRA_ROOT}/kubernetes/monitoring/loki-values.yaml" \
89+
--values "$(_k8s_file monitoring/loki-values.yaml)" \
8690
--wait \
8791
--timeout 600s
8892

@@ -92,14 +96,14 @@ helm upgrade --install promtail grafana/promtail \
9296
--version "${PROMTAIL_VERSION}" \
9397
--namespace monitoring \
9498
--create-namespace \
95-
--values "${INFRA_ROOT}/kubernetes/monitoring/promtail-values.yaml" \
99+
--values "$(_k8s_file monitoring/promtail-values.yaml)" \
96100
--wait \
97101
--timeout 600s
98102

99103
# --- 5. Grafana IngressRoute + TLS + Logs Dashboard ---
100104
log_step "[5/5] Grafana IngressRoute + TLS Certificate + Logs Dashboard..."
101-
GRAFANA_DOMAIN="${GRAFANA_DOMAIN}" envsubst < "${INFRA_ROOT}/kubernetes/monitoring/grafana-ingress.yaml" | kubectl apply -f -
102-
kubectl apply -f "${INFRA_ROOT}/kubernetes/monitoring/grafana-logs-dashboard.yaml"
105+
GRAFANA_DOMAIN="${GRAFANA_DOMAIN}" envsubst < "$(_k8s_file monitoring/grafana-ingress.yaml)" | kubectl apply -f -
106+
kubectl apply -f "$(_k8s monitoring/grafana-logs-dashboard.yaml)"
103107

104108
echo ""
105109
log_ok "Observability stack deployed!"

0 commit comments

Comments
 (0)