26 lines
877 B
Bash
26 lines
877 B
Bash
#!/usr/bin/env bash
|
|
set -Eeuo pipefail
|
|
|
|
export KUBECONFIG=/opt/cks-lab/kubeconfig
|
|
expected_context=kind-cks-lab
|
|
context="$(kubectl config current-context 2>/dev/null || true)"
|
|
|
|
if [[ "$context" != "$expected_context" ]]; then
|
|
echo "Safety check failed: expected $expected_context, got ${context:-none}." >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "CKS lab: $(kubectl version --output=json | jq -r .serverVersion.gitVersion)"
|
|
echo "Context: $context"
|
|
required_tools=(kubectl kube-bench nano vim curl wget jq yq dig nc ss ps less)
|
|
missing_tools=()
|
|
for tool in "${required_tools[@]}"; do
|
|
command -v "$tool" >/dev/null 2>&1 || missing_tools+=("$tool")
|
|
done
|
|
if (( ${#missing_tools[@]} )); then
|
|
echo "Lab setup incomplete; missing: ${missing_tools[*]}. Run ./02-install-and-build.ps1." >&2
|
|
exit 1
|
|
fi
|
|
echo "Tools: ready (nano, curl, wget, jq, yq, dig, nc, tcpdump, ss); alias k=kubectl"
|
|
exec bash
|