refactor
Some checks failed
Build, test, publish, deploy / build-test (push) Has been cancelled
Build, test, publish, deploy / publish (push) Has been cancelled
Build, test, publish, deploy / deploy-prd (push) Has been cancelled

This commit is contained in:
Daniel Noulet 2026-10-10 02:30:24 +02:00
parent 2967f1a5af
commit 618b700feb
6 changed files with 738 additions and 0 deletions

43
hack/deploy-lcl.sh Executable file
View file

@ -0,0 +1,43 @@
#!/usr/bin/env bash
#
# deploy-lcl.sh — build go-bananas, push it to the local registry, and deploy it to
# the lcl k3s cluster, then verify it is live through the TLS edge.
#
# Thin wrapper around `make deploy-lcl` that adds the two things that actually go
# wrong locally: talking to the cluster, and pulling a stale cached image.
#
# ./hack/deploy-lcl.sh
# KUBECONFIG=/etc/rancher/k3s/k3s.yaml ./hack/deploy-lcl.sh
# LCL_TAG=v1.2.3 ./hack/deploy-lcl.sh
#
set -euo pipefail
cd "$(dirname "$0")/.."
LCL_REGISTRY="${LCL_REGISTRY:-localhost:5000}"
LCL_NAMESPACE="${LCL_NAMESPACE:-go-insane-lcl}"
# Prefer an explicit KUBECONFIG; otherwise try the direct k3s config if the current
# context cannot reach a node. The default `local` context routes through a Rancher
# proxy that can 502, and a deploy against it fails with a confusing transport error
# rather than a real one.
if [ -z "${KUBECONFIG:-}" ]; then
if ! timeout 10 kubectl get nodes >/dev/null 2>&1 && [ -r /etc/rancher/k3s/k3s.yaml ]; then
echo "note: current kube context cannot reach a node; using /etc/rancher/k3s/k3s.yaml" >&2
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
fi
fi
echo "=== preflight ==="
timeout 6 curl -sf "${LCL_REGISTRY}/v2/" >/dev/null || {
echo "error: no registry answering at ${LCL_REGISTRY}/v2 — start it before deploying" >&2
exit 1
}
kubectl get nodes >/dev/null 2>&1 || {
echo "error: cannot reach the cluster (KUBECONFIG=${KUBECONFIG:-<default>})" >&2
exit 1
}
echo "registry OK (${LCL_REGISTRY}) ; cluster OK ($(kubectl config current-context 2>/dev/null || echo "$KUBECONFIG"))"
echo "=== build + push + deploy + verify ==="
exec make deploy-lcl LCL_NAMESPACE="$LCL_NAMESPACE"