feat: harden Gate 1 manifests and runbook
- add read-only make gate1-check: permissions, guardrails, dry-run, Secret keys - set numeric runAsUser/runAsGroup (SKE non-numeric user caveat), pin cloudflared and use HTTP/2 - align ML env with PULSECAST_* and wire CONTROL_TOKEN for API/ML training proxy - fix service worktree paths and smoke.sh executable bit - pin k6 v2.0.0 for xk6-sse, fix closed-connection metric and initial scenario latency - rewrite docs/deploy.md as an exact copy-paste Gate 1 checklist
This commit is contained in:
1 parent
55dfe8b616
commit
5b199f8fe3
13 files changed
+1231
-235
No files matched your search
@@ -16,13 +16,15 @@ WEB_IMAGE ?= $(REGISTRY)/$(OWNER)/pulsecast-web:$(TAG)
|
||||
API_IMAGE ?= $(REGISTRY)/$(OWNER)/pulsecast-api:$(TAG)
|
||||
ML_IMAGE ?= $(REGISTRY)/$(OWNER)/pulsecast-ml:$(TAG)
|
||||
|
||||
# Service checkouts live beside the main checkout or in per-task worktrees:
|
||||
# Hackathon_2026/worktrees/<repo>/<branch>
|
||||
# Service repos are bare Git repos beside this one, each with per-task worktrees:
|
||||
# Hackathon_2026/web-nuxt.git/feat-web-bootstrap
|
||||
# Hackathon_2026/api-go.git/feat-api-bootstrap
|
||||
# Hackathon_2026/ML-py.git/feat-ml-bootstrap
|
||||
# Override any *_DIR on the command line when the layout differs.
|
||||
SERVICES_ROOT ?= $(if $(wildcard $(abspath $(ROOT)/../../..)/worktrees),$(abspath $(ROOT)/../../..),$(abspath $(ROOT)/..))
|
||||
WEB_DIR ?= $(or $(firstword $(wildcard $(SERVICES_ROOT)/worktrees/web-nuxt/*) $(wildcard $(SERVICES_ROOT)/web-nuxt)),$(SERVICES_ROOT)/web-nuxt)
|
||||
API_DIR ?= $(or $(firstword $(wildcard $(SERVICES_ROOT)/worktrees/api-go/*) $(wildcard $(SERVICES_ROOT)/api-go)),$(SERVICES_ROOT)/api-go)
|
||||
ML_DIR ?= $(or $(firstword $(wildcard $(SERVICES_ROOT)/worktrees/ML-py/*) $(wildcard $(SERVICES_ROOT)/ML-py)),$(SERVICES_ROOT)/ML-py)
|
||||
SERVICE_REPOS ?= $(abspath $(ROOT)/../..)
|
||||
WEB_DIR ?= $(or $(firstword $(wildcard $(SERVICE_REPOS)/web-nuxt.git/feat-*)),$(firstword $(wildcard $(SERVICE_REPOS)/web-nuxt.git/main)))
|
||||
API_DIR ?= $(or $(firstword $(wildcard $(SERVICE_REPOS)/api-go.git/feat-*)),$(firstword $(wildcard $(SERVICE_REPOS)/api-go.git/main)))
|
||||
ML_DIR ?= $(or $(firstword $(wildcard $(SERVICE_REPOS)/ML-py.git/feat-*)),$(firstword $(wildcard $(SERVICE_REPOS)/ML-py.git/main)))
|
||||
|
||||
WEB_URL ?= https://pulse.noelsabia.dev
|
||||
API_URL ?= https://api.pulse.noelsabia.dev
|
||||
@@ -36,10 +38,13 @@ SSE_HOLD_PINGS ?= 20
|
||||
SSE_MAX_DURATION ?= 6m
|
||||
K6 ?=
|
||||
K6_BIN ?= $(ROOT)/k6/k6-sse
|
||||
# xk6-sse v0.2.0 exposes client.on/client.close correctly on k6 v2.0.x but not
|
||||
# on v2.4.0 (verified 2026-11-14). Pin the known-good k6 version.
|
||||
K6_BUILD_VERSION ?= v2.0.0
|
||||
K6_SCRIPT := $(ROOT)/k6/sse.js
|
||||
K6_RESULTS := $(ROOT)/k6/results
|
||||
|
||||
.PHONY: help validate validate-kubeconform build build-web build-api build-ml push push-web push-api push-ml set-image deploy deploy-check status logs smoke smoke-local load k6-build secret-commands clean
|
||||
.PHONY: help validate validate-kubeconform gate1-check build build-web build-api build-ml push push-web push-api push-ml set-image restart deploy deploy-check status logs smoke smoke-local load k6-build secret-commands clean
|
||||
|
||||
help: ## Show available targets
|
||||
@awk 'BEGIN {FS = ":.*## "} /^[a-zA-Z0-9_-]+:.*## / {printf " %-22s %s\n", $$1, $$2}' $(MAKEFILE_LIST)
|
||||
@@ -49,9 +54,9 @@ validate: ## Validate deploy/k8s read-only (schema when possible, never applies)
|
||||
if command -v "$(KUBECONFORM)" >/dev/null 2>&1; then \
|
||||
echo "== kubeconform (strict, offline schemas)"; \
|
||||
"$(KUBECONFORM)" -strict -summary -ignore-missing-schemas "$(ROOT)/deploy/k8s"; \
|
||||
elif command -v kubectl >/dev/null 2>&1 && kubectl cluster-info >/dev/null 2>&1; then \
|
||||
elif command -v kubectl >/dev/null 2>&1 && kubectl --context "$(CONTEXT)" get --raw=/readyz --request-timeout=5s >/dev/null 2>&1; then \
|
||||
echo "== kubectl client dry-run (read-only)"; \
|
||||
kubectl apply --dry-run=client -f "$(ROOT)/deploy/k8s"; \
|
||||
$(KUBECTL) apply --dry-run=client -f "$(ROOT)/deploy/k8s"; \
|
||||
else \
|
||||
echo "== YAML syntax only: kubeconform is not installed and no cluster is reachable"; \
|
||||
"$(PYTHON)" -c "import glob, yaml; docs=[d for f in sorted(glob.glob('$(ROOT)/deploy/k8s/*.yaml')) for d in yaml.safe_load_all(open(f)) if d]; assert all(isinstance(d, dict) and d.get('apiVersion') and d.get('kind') for d in docs), 'manifest missing apiVersion/kind'; print(f'{len(docs)} manifests parsed')"; \
|
||||
@@ -62,6 +67,10 @@ validate-kubeconform: ## Validate schemas with kubeconform (must be installed)
|
||||
@command -v "$(KUBECONFORM)" >/dev/null 2>&1 || { echo "kubeconform not found; go install github.com/yannh/kubeconform/cmd/kubeconform@latest"; exit 1; }
|
||||
"$(KUBECONFORM)" -strict -summary -ignore-missing-schemas "$(ROOT)/deploy/k8s"
|
||||
|
||||
gate1-check: ## Read-only Gate 1 readiness: permissions, guardrails, dry-run, Secrets (never mutates)
|
||||
@NS="$(NAMESPACE)" CONTEXT="$(CONTEXT)" REGISTRY="$(REGISTRY)" OWNER="$(OWNER)" TAG="$(TAG)" \
|
||||
"$(ROOT)/scripts/gate1-check.sh"
|
||||
|
||||
build: build-web build-api build-ml ## Build all three images locally
|
||||
|
||||
build-web: ## Build the web image
|
||||
@@ -97,12 +106,22 @@ set-image: ## Update live Deployments to TAG (guarded; human only)
|
||||
$(KUBECTL) set image deployment/ml ml="$(ML_IMAGE)"
|
||||
$(KUBECTL) rollout status deployment/web deployment/api deployment/ml --timeout=180s
|
||||
|
||||
deploy-check: ## Verify required Secrets exist (read-only)
|
||||
restart: ## Force a re-pull/restart of web, api, ml after re-pushing the same tag (guarded)
|
||||
@test "$(CONFIRM)" = "yes" || { echo "Refusing: re-run with CONFIRM=yes (cluster mutation)"; exit 1; }
|
||||
$(KUBECTL) rollout restart deployment/web deployment/api deployment/ml
|
||||
$(KUBECTL) rollout status deployment/web deployment/api deployment/ml --timeout=180s
|
||||
|
||||
deploy-check: ## Verify required Secrets and keys exist (read-only)
|
||||
@for s in gitea-regcred cloudflared control-auth; do \
|
||||
$(KUBECTL) get secret "$$s" >/dev/null 2>&1 || { \
|
||||
echo "Missing Secret $$s in $(NAMESPACE); see docs/deploy.md"; exit 1; }; \
|
||||
done
|
||||
@echo "required Secrets present"
|
||||
@for ref in cloudflared:TUNNEL_TOKEN control-auth:CONTROL_USER control-auth:CONTROL_PASS control-auth:CONTROL_TOKEN; do \
|
||||
secret="$${ref%%:*}"; key="$${ref#*:}"; \
|
||||
value="$$($(KUBECTL) get secret "$$secret" -o jsonpath="{.data.$$key}" 2>/dev/null || true)"; \
|
||||
test -n "$$value" || { echo "Secret $$secret is missing key $$key; see docs/deploy.md"; exit 1; }; \
|
||||
done
|
||||
@echo "required Secrets and keys present"
|
||||
|
||||
deploy: ## Apply manifests (guarded; human only)
|
||||
@test "$(CONFIRM)" = "yes" || { echo "Refusing: re-run with CONFIRM=yes (cluster mutation)"; exit 1; }
|
||||
@@ -154,8 +173,11 @@ load: ## Run the 120-client / 5-minute SSE load test
|
||||
k6-build: ## Build a k6 binary with the SSE extension (k6/k6-sse)
|
||||
@command -v go >/dev/null 2>&1 || { echo "Go is required to build xk6"; exit 1; }
|
||||
@cd "$(ROOT)/k6" && GOBIN="$(ROOT)/k6" go install go.k6.io/xk6/cmd/xk6@latest
|
||||
@cd "$(ROOT)/k6" && "$(ROOT)/k6/xk6" build --with github.com/phymbert/xk6-sse@latest --output "$(ROOT)/k6/k6-sse"
|
||||
@echo "Built $(ROOT)/k6/k6-sse"
|
||||
@cd "$(ROOT)/k6" && "$(ROOT)/k6/xk6" build \
|
||||
--k6-version "$(K6_BUILD_VERSION)" \
|
||||
--with github.com/phymbert/xk6-sse@latest \
|
||||
--output "$(ROOT)/k6/k6-sse"
|
||||
@echo "Built $(ROOT)/k6/k6-sse (k6 $(K6_BUILD_VERSION) + xk6-sse)"
|
||||
|
||||
secret-commands: ## Print the exact Secret creation commands (creates nothing)
|
||||
@echo "kubectl --context $(CONTEXT) -n $(NAMESPACE) create secret generic cloudflared \\"
|
||||
@@ -163,7 +185,8 @@ secret-commands: ## Print the exact Secret creation commands (creates nothing)
|
||||
@echo
|
||||
@echo "kubectl --context $(CONTEXT) -n $(NAMESPACE) create secret generic control-auth \\"
|
||||
@echo " --from-literal=CONTROL_USER='<control user>' \\"
|
||||
@echo " --from-literal=CONTROL_PASS='<strong password>'"
|
||||
@echo " --from-literal=CONTROL_PASS='<strong password>' \\"
|
||||
@echo " --from-literal=CONTROL_TOKEN='<random token shared by API and ML>'"
|
||||
@echo
|
||||
@echo "kubectl --context $(CONTEXT) -n $(NAMESPACE) create secret docker-registry gitea-regcred \\"
|
||||
@echo " --docker-server=$(REGISTRY) \\"
|
||||
|
||||
Reference in new issue
Block a user