Skip to content

Commit 984afec

Browse files
committed
lab32: Add EFK stack - Helm charts, ArgoCD apps, scripts, README
1 parent cec8293 commit 984afec

60 files changed

Lines changed: 3716 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Labs/32-EFK/.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Offline artifacts - charts
2+
artifacts/charts/*.tgz
3+
4+
# Offline artifacts - images
5+
artifacts/images/*.tar
6+
7+
# Offline artifacts - harbor
8+
artifacts/harbor/*.tgz
9+
artifacts/harbor/*.tar
10+
11+
# Offline artifacts - ingress
12+
artifacts/ingress/*.tgz
13+
artifacts/ingress/*.tar

Labs/32-EFK/access-kibana.sh

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
#!/bin/bash
2+
3+
# Quick Access Guide for EFK Stack
4+
# This script helps you access Kibana via Ingress
5+
6+
# Colors
7+
GREEN='\033[0;32m'
8+
BLUE='\033[0;34m'
9+
YELLOW='\033[1;33m'
10+
NC='\033[0m'
11+
12+
echo -e "${BLUE}=== EFK Stack - Kibana Access ===${NC}"
13+
echo ""
14+
15+
# Get ingress information
16+
INGRESS_IP=$(kubectl get ingress -n efk kibana -o jsonpath='{.status.loadBalancer.ingress[0].ip}' 2>/dev/null)
17+
INGRESS_HOST=$(kubectl get ingress -n efk kibana -o jsonpath='{.spec.rules[0].host}' 2>/dev/null)
18+
19+
if [ -z "$INGRESS_HOST" ]; then
20+
echo -e "${YELLOW}⚠ Ingress not found. Is the EFK stack deployed?${NC}"
21+
echo ""
22+
echo "Deploy the stack first:"
23+
echo " ./demo.sh deploy"
24+
exit 1
25+
fi
26+
27+
echo -e "${GREEN}✓ Ingress Found${NC}"
28+
echo " Host: $INGRESS_HOST"
29+
echo " IP: ${INGRESS_IP:-<pending>}"
30+
echo ""
31+
32+
# Check /etc/hosts
33+
if grep -q "$INGRESS_HOST" /etc/hosts; then
34+
echo -e "${GREEN}✓ /etc/hosts configured${NC}"
35+
HOSTS_IP=$(grep "$INGRESS_HOST" /etc/hosts | awk '{print $1}' | head -1)
36+
echo " Entry: $HOSTS_IP $INGRESS_HOST"
37+
else
38+
echo -e "${YELLOW}⚠ /etc/hosts not configured${NC}"
39+
echo ""
40+
echo "Add the following to /etc/hosts:"
41+
echo " ${INGRESS_IP:-192.168.139.2} $INGRESS_HOST"
42+
echo ""
43+
echo "Run this command:"
44+
echo " echo \"${INGRESS_IP:-192.168.139.2} $INGRESS_HOST\" | sudo tee -a /etc/hosts"
45+
echo ""
46+
read -p "Add to /etc/hosts now? (y/n) " -n 1 -r
47+
echo
48+
if [[ $REPLY =~ ^[Yy]$ ]]; then
49+
echo "${INGRESS_IP:-192.168.139.2} $INGRESS_HOST" | sudo tee -a /etc/hosts
50+
echo -e "${GREEN}✓ Added to /etc/hosts${NC}"
51+
fi
52+
fi
53+
54+
echo ""
55+
echo -e "${BLUE}=== Access Information ===${NC}"
56+
echo ""
57+
echo "Kibana URL:"
58+
echo -e " ${GREEN}http://$INGRESS_HOST${NC}"
59+
echo ""
60+
61+
# Test connectivity
62+
echo "Testing connectivity..."
63+
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" http://$INGRESS_HOST/api/status 2>/dev/null)
64+
65+
if [ "$HTTP_CODE" = "200" ]; then
66+
echo -e "${GREEN}✓ Kibana is accessible!${NC}"
67+
echo ""
68+
echo "Opening Kibana in browser..."
69+
echo ""
70+
71+
# Try to open in browser
72+
if command -v open &>/dev/null; then
73+
open "http://$INGRESS_HOST"
74+
elif command -v xdg-open &>/dev/null; then
75+
xdg-open "http://$INGRESS_HOST"
76+
else
77+
echo "Please open http://$INGRESS_HOST in your browser"
78+
fi
79+
80+
echo ""
81+
echo -e "${BLUE}=== Available Dashboards ===${NC}"
82+
echo " • Error Analysis Dashboard"
83+
echo " • General Logs Dashboard"
84+
echo ""
85+
echo "Navigate to 'Dashboard' in the Kibana sidebar to view them."
86+
else
87+
echo -e "${YELLOW}⚠ Cannot reach Kibana (HTTP $HTTP_CODE)${NC}"
88+
echo ""
89+
echo "Troubleshooting:"
90+
echo " 1. Check if Kibana pod is running:"
91+
echo " kubectl get pods -n efk -l app=kibana"
92+
echo ""
93+
echo " 2. Check ingress status:"
94+
echo " kubectl describe ingress -n efk kibana"
95+
echo ""
96+
echo " 3. Use port-forward as alternative:"
97+
echo " kubectl port-forward -n efk svc/kibana 5601:5601"
98+
echo " Then open: http://localhost:5601"
99+
fi
100+
101+
echo ""

Labs/32-EFK/airgap.sh

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
#!/bin/bash
2+
# =============================================================================
3+
# Master orchestration script for EFK offline deployment with Harbor
4+
# =============================================================================
5+
set -euo pipefail
6+
7+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8+
source "${SCRIPT_DIR}/scripts/common.sh"
9+
load_env
10+
11+
usage() {
12+
echo "Usage: $0 <command>"
13+
echo ""
14+
echo "Commands:"
15+
echo " prepare Download all artifacts for offline use (run with internet)"
16+
echo " install Full offline installation (Ingress + Harbor + EFK)"
17+
echo " ingress Install nginx ingress controller"
18+
echo " harbor Install Harbor registry only"
19+
echo " push Load images, retag, and push to Harbor"
20+
echo " efk Install EFK stack from Harbor"
21+
echo " verify Verify the deployment is working"
22+
echo " cleanup Remove EFK stack (keeps Harbor)"
23+
echo " cleanup-all Remove everything including Harbor"
24+
echo " status Show deployment status"
25+
echo ""
26+
echo "Typical workflow:"
27+
echo " 1. $0 prepare # On internet-connected machine"
28+
echo " 2. # Transfer artifacts/ to air-gapped environment"
29+
echo " 3. $0 install # On air-gapped machine"
30+
echo ""
31+
echo "Configuration: .env"
32+
exit 1
33+
}
34+
35+
# ---- Commands ---------------------------------------------------------------
36+
37+
cmd_prepare() {
38+
print_header "Preparing Offline Artifacts"
39+
bash "${PROJECT_ROOT}/artifacts/download-all.sh"
40+
}
41+
42+
cmd_ingress() {
43+
print_header "Installing Ingress Controller"
44+
bash "${PROJECT_ROOT}/scripts/install-ingress.sh"
45+
}
46+
47+
cmd_harbor() {
48+
print_header "Installing Harbor"
49+
bash "${PROJECT_ROOT}/scripts/install-harbor.sh"
50+
}
51+
52+
cmd_push() {
53+
print_header "Pushing Content to Harbor"
54+
55+
print_step "Pushing container images..."
56+
bash "${PROJECT_ROOT}/scripts/retag-and-push-images.sh"
57+
58+
echo ""
59+
60+
print_step "Pushing Helm charts..."
61+
bash "${PROJECT_ROOT}/scripts/upload-charts-to-harbor.sh"
62+
}
63+
64+
cmd_efk() {
65+
print_header "Installing EFK from Harbor"
66+
bash "${PROJECT_ROOT}/scripts/offline-install.sh"
67+
}
68+
69+
cmd_install() {
70+
print_header "Full Offline Installation"
71+
echo ""
72+
print_info "This will: Ingress -> Harbor -> Push images/charts -> Install EFK"
73+
echo ""
74+
75+
# Step 0: Install Ingress Controller
76+
cmd_ingress
77+
echo ""
78+
79+
# Step 1: Install Harbor
80+
cmd_harbor
81+
echo ""
82+
83+
# Step 2: Push content to Harbor
84+
cmd_push
85+
echo ""
86+
87+
# Step 3: Install EFK
88+
cmd_efk
89+
echo ""
90+
91+
# Step 4: Verify
92+
cmd_verify
93+
}
94+
95+
cmd_verify() {
96+
print_header "Verifying Deployment"
97+
bash "${PROJECT_ROOT}/scripts/verify-deployment.sh"
98+
}
99+
100+
cmd_status() {
101+
print_header "Deployment Status"
102+
103+
echo ""
104+
print_step "Harbor namespace:"
105+
kubectl get pods -n "${HARBOR_NAMESPACE}" 2>/dev/null || echo " Harbor not installed"
106+
107+
echo ""
108+
print_step "EFK namespace:"
109+
kubectl get pods -n "${EFK_NAMESPACE}" 2>/dev/null || echo " EFK not installed"
110+
111+
echo ""
112+
print_step "Helm releases:"
113+
helm list -n "${HARBOR_NAMESPACE}" 2>/dev/null || true
114+
helm list -n "${EFK_NAMESPACE}" 2>/dev/null || true
115+
116+
echo ""
117+
print_step "Ingress:"
118+
kubectl get ingress -n "${EFK_NAMESPACE}" 2>/dev/null || true
119+
}
120+
121+
cmd_cleanup() {
122+
print_warning "Cleaning up EFK stack..."
123+
124+
helm uninstall log-processor -n "${EFK_NAMESPACE}" 2>/dev/null || true
125+
helm uninstall log-generator -n "${EFK_NAMESPACE}" 2>/dev/null || true
126+
helm uninstall filebeat -n "${EFK_NAMESPACE}" 2>/dev/null || true
127+
helm uninstall kibana -n "${EFK_NAMESPACE}" 2>/dev/null || true
128+
helm uninstall elasticsearch -n "${EFK_NAMESPACE}" 2>/dev/null || true
129+
130+
kubectl delete jobs -n "${EFK_NAMESPACE}" -l app=log-processor 2>/dev/null || true
131+
kubectl delete jobs -n "${EFK_NAMESPACE}" -l app=kibana-dashboard-importer 2>/dev/null || true
132+
kubectl delete namespace "${EFK_NAMESPACE}" 2>/dev/null || true
133+
134+
print_success "EFK cleanup complete"
135+
}
136+
137+
cmd_cleanup_all() {
138+
cmd_cleanup
139+
140+
print_warning "Cleaning up Harbor..."
141+
helm uninstall harbor -n "${HARBOR_NAMESPACE}" 2>/dev/null || true
142+
kubectl delete namespace "${HARBOR_NAMESPACE}" 2>/dev/null || true
143+
144+
print_warning "Cleaning up Ingress Controller..."
145+
helm uninstall ingress-nginx -n "${INGRESS_NAMESPACE}" 2>/dev/null || true
146+
kubectl delete namespace "${INGRESS_NAMESPACE}" 2>/dev/null || true
147+
148+
print_success "Full cleanup complete"
149+
}
150+
151+
# ---- Main -------------------------------------------------------------------
152+
153+
case "${1:-}" in
154+
prepare) cmd_prepare ;;
155+
install) cmd_install ;;
156+
ingress) cmd_ingress ;;
157+
harbor) cmd_harbor ;;
158+
push) cmd_push ;;
159+
efk) cmd_efk ;;
160+
verify) cmd_verify ;;
161+
cleanup) cmd_cleanup ;;
162+
cleanup-all) cmd_cleanup_all ;;
163+
status) cmd_status ;;
164+
*) usage ;;
165+
esac
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/bin/bash
2+
# =============================================================================
3+
# Download ALL artifacts needed for offline/air-gapped installation
4+
# This is the master download script that calls all sub-scripts
5+
# =============================================================================
6+
set -euo pipefail
7+
8+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
9+
source "${SCRIPT_DIR}/../scripts/common.sh"
10+
load_env
11+
12+
print_header "Download All Offline Artifacts"
13+
14+
print_info "Artifacts directory: ${ARTIFACTS_DIR}"
15+
ensure_dirs "$ARTIFACTS_DIR" "$IMAGES_DIR" "$CHARTS_DIR" "$HARBOR_CHARTS_DIR"
16+
17+
echo ""
18+
19+
# Step 1: Download images
20+
print_step "Step 1/4: Downloading container images..."
21+
bash "${SCRIPT_DIR}/download-images.sh"
22+
echo ""
23+
24+
# Step 2: Package Helm charts
25+
print_step "Step 2/4: Packaging Helm charts..."
26+
bash "${SCRIPT_DIR}/download-charts.sh"
27+
echo ""
28+
29+
# Step 3: Download Harbor images
30+
print_step "Step 3/4: Downloading Harbor container images..."
31+
bash "${SCRIPT_DIR}/download-harbor-images.sh"
32+
echo ""
33+
34+
# Step 4: Download Ingress controller images
35+
print_step "Step 4/4: Downloading Ingress controller images..."
36+
bash "${SCRIPT_DIR}/download-ingress-images.sh"
37+
echo ""
38+
39+
# Final summary
40+
print_header "All Artifacts Downloaded"
41+
echo ""
42+
print_info "Directory structure:"
43+
find "$ARTIFACTS_DIR" -type f | sort | while read -r f; do
44+
SIZE=$(du -h "$f" | cut -f1)
45+
REL=$(echo "$f" | sed "s|${ARTIFACTS_DIR}/||")
46+
echo " ${REL} (${SIZE})"
47+
done
48+
49+
TOTAL_SIZE=$(du -sh "$ARTIFACTS_DIR" | cut -f1)
50+
echo ""
51+
print_success "Total artifact size: $TOTAL_SIZE"
52+
echo ""
53+
print_info "Next steps:"
54+
echo " 1. Transfer the artifacts/ directory to the air-gapped environment"
55+
echo " 2. Run: ./scripts/install-harbor.sh # Install Harbor registry"
56+
echo " 3. Run: ./scripts/retag-and-push-images.sh # Push images to Harbor"
57+
echo " 4. Run: ./scripts/offline-install.sh # Install EFK from Harbor"

0 commit comments

Comments
 (0)