Add automated build-and-deploy Makefile target and update dashboard metadata

This commit is contained in:
Stephen Schuresko
2026-09-24 08:17:53 -04:00
parent cc29f00e1e
commit 6202ed7628
2 changed files with 118 additions and 9 deletions

113
Makefile
View File

@@ -1,28 +1,125 @@
IMAGE ?= localhost:32000/systemd-runner:latest
NAMESPACE ?= default
GATEWAY_APP ?= zero-scale-gateway
APPS_DIR ?= /opt/apps
.PHONY: all build image push deploy restart clean
.PHONY: all build build-gateway build-dashboard build-mock \
deploy deploy-manifests deploy-dashboard build-and-deploy \
image push restart full-deploy ship verify status clean
all: build
build:
# -------------------------------------------------------------
# Compilation Targets
# -------------------------------------------------------------
build: build-gateway build-mock build-dashboard
@echo "==> All binaries built successfully."
build-gateway:
@echo "==> Building gateway..."
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o gateway ./cmd/gateway
build-mock:
@echo "==> Building mock-app..."
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o mock-app ./cmd/mock-app
build-dashboard:
@echo "==> Building zero-scale-dashboard..."
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o zero-scale-dashboard ./cmd/zero-scale-dashboard
# -------------------------------------------------------------
# Kubernetes Manifests
# -------------------------------------------------------------
deploy-manifests:
@echo "==> Applying all Kubernetes manifests in deploy/ to namespace '$(NAMESPACE)'..."
kubectl apply -f deploy/ -n $(NAMESPACE)
# -------------------------------------------------------------
# Zero-Scale Dashboard Deployment (Binary + Symlinks + Unit Reset)
# -------------------------------------------------------------
deploy-dashboard: build-dashboard
@echo "==> Deploying zero-scale-dashboard to active pod in namespace '$(NAMESPACE)'..."
@POD=$$(kubectl get pods -l app=$(GATEWAY_APP) -n $(NAMESPACE) --field-selector=status.phase=Running -o jsonpath='{.items[0].metadata.name}'); \
if [ -z "$$POD" ]; then \
echo "ERROR: No running pod found with label app=$(GATEWAY_APP) in namespace $(NAMESPACE)"; \
exit 1; \
fi; \
echo "--> Target Pod: $$POD"; \
echo "--> Copying zero-scale-dashboard binary to $(APPS_DIR)/status.kube.fairfaxmedia.net..."; \
kubectl cp zero-scale-dashboard $(NAMESPACE)/$$POD:$(APPS_DIR)/status.kube.fairfaxmedia.net -c systemd-runner; \
kubectl exec $$POD -n $(NAMESPACE) -c systemd-runner -- chmod +x $(APPS_DIR)/status.kube.fairfaxmedia.net; \
echo "--> Creating host symlinks (status.fairfaxmedia.net, kstat.fairfaxmedia.net, kstat.kube.fairfaxmedia.net)..."; \
kubectl exec $$POD -n $(NAMESPACE) -c systemd-runner -- ln -sf $(APPS_DIR)/status.kube.fairfaxmedia.net $(APPS_DIR)/status.fairfaxmedia.net; \
kubectl exec $$POD -n $(NAMESPACE) -c systemd-runner -- ln -sf $(APPS_DIR)/status.kube.fairfaxmedia.net $(APPS_DIR)/kstat.fairfaxmedia.net; \
kubectl exec $$POD -n $(NAMESPACE) -c systemd-runner -- ln -sf $(APPS_DIR)/status.kube.fairfaxmedia.net $(APPS_DIR)/kstat.kube.fairfaxmedia.net; \
echo "--> Resetting transient service units for clean reload..."; \
kubectl exec $$POD -n $(NAMESPACE) -c systemd-runner -- systemctl stop \
app-status.kube.fairfaxmedia.net.service \
app-status.fairfaxmedia.net.service \
app-kstat.fairfaxmedia.net.service \
app-kstat.kube.fairfaxmedia.net.service 2>/dev/null || true; \
echo "==> Dashboard deployed and host mappings active."
# -------------------------------------------------------------
# Health Check Verification
# -------------------------------------------------------------
verify:
@echo "==> Verifying live dashboard endpoints..."
@echo -n "Checking https://status.kube.fairfaxmedia.net/ ... "; \
STATUS1=$$(curl -4 -k -s -o /dev/null -w "%{http_code}" --connect-timeout 8 https://status.kube.fairfaxmedia.net/ || echo "ERR"); \
echo "$$STATUS1"; \
echo -n "Checking https://kstat.fairfaxmedia.net/ ... "; \
STATUS2=$$(curl -k -s -o /dev/null -w "%{http_code}" --connect-timeout 8 https://kstat.fairfaxmedia.net/ || echo "ERR"); \
echo "$$STATUS2"; \
if [ "$$STATUS1" = "200" ] && [ "$$STATUS2" = "200" ]; then \
echo "==> All endpoints operational (200 OK)!"; \
else \
echo "WARNING: Some endpoints did not return 200 OK (status.kube: $$STATUS1, kstat: $$STATUS2)"; \
fi
# -------------------------------------------------------------
# Combined Deploy & Build-and-Deploy
# -------------------------------------------------------------
deploy: deploy-manifests deploy-dashboard verify
@echo "==> Deployment complete."
build-and-deploy: build deploy
@echo "==> Build and Deploy successfully finished!"
# -------------------------------------------------------------
# Container Image & Full Cluster Rollout
# -------------------------------------------------------------
image: build
@echo "==> Building Docker image $(IMAGE)..."
docker build -t $(IMAGE) -f Dockerfile.systemd .
push: image
@echo "==> Pushing Docker image $(IMAGE)..."
docker push $(IMAGE)
deploy:
kubectl apply -f deploy/deployment.yaml -n $(NAMESPACE)
kubectl apply -f deploy/service.yaml -n $(NAMESPACE)
kubectl apply -f deploy/ingress.yaml -n $(NAMESPACE)
restart:
kubectl rollout restart deployment/zero-scale-gateway -n $(NAMESPACE)
@echo "==> Restarting deployment $(GATEWAY_APP)..."
kubectl rollout restart deployment/$(GATEWAY_APP) -n $(NAMESPACE)
kubectl rollout status deployment/$(GATEWAY_APP) -n $(NAMESPACE) --timeout=120s
full-deploy: build image push deploy-manifests restart deploy-dashboard verify
@echo "==> Full stack container build and deployment complete!"
ship: full-deploy
# -------------------------------------------------------------
# Status & Inspection
# -------------------------------------------------------------
status:
@echo "==> Cluster Pods:"
@kubectl get pods -l app=$(GATEWAY_APP) -n $(NAMESPACE)
@echo "\n==> Ingresses:"
@kubectl get ingress -l app=$(GATEWAY_APP) -n $(NAMESPACE)
@echo "\n==> Live Apps in $(APPS_DIR):"
@POD=$$(kubectl get pods -l app=$(GATEWAY_APP) -n $(NAMESPACE) --field-selector=status.phase=Running -o jsonpath='{.items[0].metadata.name}'); \
if [ -n "$$POD" ]; then \
kubectl exec $$POD -n $(NAMESPACE) -c systemd-runner -- ls -la $(APPS_DIR); \
fi
clean:
rm -f gateway mock-app zero-scale-dashboard status-dashboard

View File

@@ -4,7 +4,19 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Zero-Scale Platform Dashboard</title>
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>☸️</text></svg>">
<meta name="description" content="Real-time operational telemetry and infrastructure monitoring for the Zero-Scale Platform on Kubernetes.">
<meta name="robots" content="index, follow">
<link rel="canonical" href="https://kstat.fairfaxmedia.net/">
<!-- Open Graph Metadata -->
<meta property="og:title" content="Zero-Scale Platform Dashboard">
<meta property="og:description" content="Real-time operational telemetry and infrastructure monitoring for the Zero-Scale Platform on Kubernetes.">
<meta property="og:type" content="website">
<meta property="og:url" content="https://kstat.fairfaxmedia.net/">
<meta property="og:site_name" content="Zero-Scale Platform">
<link rel="icon" href="https://git.fairfaxmedia.net/assets/img/logo.svg" type="image/svg+xml">
<link rel="alternate icon" href="https://git.fairfaxmedia.net/assets/img/favicon.png" type="image/png">
<style>
:root {
--bg: #090d16;