prole/Makefile
chrisfu d114801758 feat: wire ekosystem UUID system into CNPG manifests (Tasks 1, 3, 4)
Task 1 — ConfigMap + CNPG wiring:
- Add k8s/knoe/knoe-ekosystem-sql.yaml: ConfigMap embedding ekosystem.sql
  and ekosystem_objects.sql for CNPG postInitApplicationSQLRefs
- Add scripts/gen-ekosystem-configmap.py: generation script to keep the
  ConfigMap in sync with knoe-db/schema/ekosystem*.sql source files
- Add Makefile target: make k8s/knoe/knoe-ekosystem-sql.yaml
- Wire postInitApplicationSQLRefs into all three CNPG cluster manifests:
    k8s/knoe/knoe-db.yaml (k3s / prole-service-context production)
    deploy/gcp/gke/knoe-db.yaml (GKE)
    deploy/opentofu/k3s/manifests/knoe/knoe-db.yaml (OpenTofu k3s)
- Add knoe-ekosystem-sql.yaml to k8s/knoe/kustomization.yaml

Task 3 — Python counterpart utility:
- Add knoe/ekosystem.py: thread-safe EkosystemID generator matching the
  PostgreSQL bit layout [49:ts_ms|12:tenant|10:shard|11:seq], with
  decode() and can_access() helpers
- Add tests/test_ekosystem.py: 23 tests covering base36 encoding,
  round-trips, thread safety, can_access, and the spec round-trip assertion

Task 4 — knoe.user ekosystem_uuid column:
- Add ALTER TABLE knoe.user ADD COLUMN IF NOT EXISTS ekosystem_uuid text UNIQUE
  to postInitSQL in all three CNPG manifests

Task 2 (register prole tenant) requires a live DB connection — manual step.
Task 5 (LDAP/AD reconciler) is design-only per spec.

Co-authored-by: Junie <junie@jetbrains.com>
2026-05-30 00:26:48 -07:00

140 lines
5.6 KiB
Makefile

# Makefile for Knoe Database Deployment and Installer
ifneq ($(wildcard bin/python3),)
PYTHON ?= bin/python3
else
PYTHON ?= python3
endif
PYINSTALLER = $(PYTHON) -m PyInstaller
DIST_DIR = dist
BUILD_DIR = build
KNOE_CONF ?= conf
KNOE_MODE ?= k3d
PIPELINE_DIR ?= deploy/opentofu/k3s
DEPLOYMENT_GIT_DIR ?= knoe/deployment
GITEA_SCRIPT ?= knoe/etc/gitea.sh
KUBECONFIG_PATH ?= $(CURDIR)/knoe-k3s.kubeconfig
REGISTRY ?= us-west3-docker.pkg.dev/plenary-truck-485623-p7/knoe-system
KNOE_AUTH_VERSION ?= latest
DEPLOYMENT_REPO_URL ?= http://gitea.local/knoe/deployment.git
.PHONY: all knoe build build-auth docker-build-auth docker-push-auth install deploy init clean help requirements test pyconv start \
k3d-knoe-up k3d-knoe-pf k3d-knoe-down \
workstation
all: build
start: build
open "$(DIST_DIR)/Knoe.DB Installer.app"
help:
@echo "Knoe Build & Deployment System"
@echo ""
@echo "Targets:"
@echo " knoe - Launch the Ncurses installer"
@echo " start - Build and launch the GUI installer"
@echo " install - Run silent install via install.sh"
@echo " deploy - Run infrastructure deployment via deploy.sh"
@echo " build - Build the 'knoe' CLI binary"
@echo " build-auth - Build the knoe-auth Spring Boot jar (authority/pom.xml)"
@echo " workstation - Configure Kerberos + Chrome SPNEGO on this machine"
@echo " requirements - Install Python dependencies"
@echo " test - Run full test suite"
@echo " pyconv - Check Python code style conventions (black)"
@echo " clean - Remove build artifacts"
@echo ""
@echo "Environment:"
@echo " KNOE_CONF - Directory containing knoe.cfg (default: conf)"
@echo ""
@echo "k3d dev loop targets:"
@echo " k3d-knoe-up - Bring up local k3d cluster (CNPG + KDC + schema)"
@echo " k3d-knoe-pf - Open port-forwards (5432/88/464) — foreground, ^C to stop"
@echo " k3d-knoe-down - Tear down the k3d-knoe cluster"
requirements:
@echo "Installing dependencies..."
$(PYTHON) -m pip install -r requirements.txt
knoe:
./install.sh
build:
@$(PYTHON) -c "import PyInstaller" 2>/dev/null || (echo "Error: PyInstaller not found. Please run 'make requirements' or install it with: $(PYTHON) -m pip install -r requirements.txt" && exit 1)
@echo "Building 'Knoe.DB Installer' macOS App Bundle..."
$(PYINSTALLER) --clean --noconfirm knoe.spec
@echo "✓ Build complete: $(DIST_DIR)/Knoe.DB Installer.app"
build-auth:
@command -v mvn >/dev/null 2>&1 || (echo "Error: mvn not found in PATH." && exit 1)
@echo "Building knoe-auth (dev.knoe:auth) via authority/pom.xml..."
mvn -f authority/pom.xml -DskipTests package
@echo "✓ knoe-auth jar: authority/target/knoe-auth.jar"
docker-build-auth: build-auth
@command -v docker >/dev/null 2>&1 || (echo "Error: docker not found in PATH." && exit 1)
@echo "Building Docker image knoe-auth:$(KNOE_AUTH_VERSION)..."
docker build -f authority/Dockerfile.app -t knoe-auth:$(KNOE_AUTH_VERSION) .
@echo "✓ Docker image: knoe-auth:$(KNOE_AUTH_VERSION)"
docker-push-auth: docker-build-auth
@echo "Tagging and pushing $(REGISTRY)/knoe-auth:$(KNOE_AUTH_VERSION)..."
docker tag knoe-auth:$(KNOE_AUTH_VERSION) $(REGISTRY)/knoe-auth:$(KNOE_AUTH_VERSION)
docker push $(REGISTRY)/knoe-auth:$(KNOE_AUTH_VERSION)
@echo "✓ Pushed: $(REGISTRY)/knoe-auth:$(KNOE_AUTH_VERSION)"
install:
@echo "Running silent install..."
KNOE_CONF=$(KNOE_CONF) ./install.sh -s -c $(KNOE_CONF)/knoe.cfg
init:
@command -v tofu >/dev/null 2>&1 || (echo "Error: OpenTofu (tofu) not found in PATH." && exit 1)
@echo "Syncing OpenTofu pipeline from $(KNOE_MODE) runtime into $(PIPELINE_DIR)..."
@KNOE_MODE=$(KNOE_MODE) KNOE_CONF=$(KNOE_CONF) KNOE_GIT_REPO=$(DEPLOYMENT_REPO_URL) PYTHONPATH=$(CURDIR) $(PYTHON) -c "from knoe.core.controller import KnoeController; from knoe.core.env import PROJECT_ROOT; from knoe.deployment import KnoeDeployment; import sys, os; conf_dir = os.environ.get('KNOE_CONF', 'conf'); cfg_path = PROJECT_ROOT / conf_dir / 'knoe.cfg'; deployment = KnoeDeployment(KnoeController(PROJECT_ROOT, verbose=False, cfg_path=cfg_path), PROJECT_ROOT); ok = deployment.duplicate_k3d_to_k3s(); sys.exit(0 if ok else 1)"
@echo "Initializing OpenTofu backend in $(PIPELINE_DIR)..."
@cd $(PIPELINE_DIR) && tofu init
@echo "Staging pipeline sources into $(DEPLOYMENT_GIT_DIR) for Gitea"
@mkdir -p $(DEPLOYMENT_GIT_DIR)
@if command -v rsync >/dev/null 2>&1; then rsync -a $(PIPELINE_DIR)/ $(DEPLOYMENT_GIT_DIR)/; else cp -a $(PIPELINE_DIR)/. $(DEPLOYMENT_GIT_DIR)/; fi
@cd $(DEPLOYMENT_GIT_DIR) && if [ ! -d .git ]; then git init -q; fi
@echo "✓ init complete"
deploy:
@echo "Running Knoe deployment..."
./deploy.sh
workstation:
@echo "Configuring Kerberos + Chrome SPNEGO on this machine..."
@echo "(You will be prompted for your sudo password)"
@bash infrastructure/bin/install_workstation.sh
test: pyconv
@echo "Running full test suite..."
@./tests/run_tests.sh
@echo ""
@echo "Test Summary:"
@$(PYTHON) -m coverage report | grep TOTAL | awk '{print "Total Coverage: " $$4 " (Statements: " $$2 ", Missed: " $$3 ")"}'
pyconv:
@echo "Checking Python code style conventions..."
@$(PYTHON) -m black --check . || (echo "Warning: pyconv (black) found style issues. Run 'black .' to fix." && exit 1)
k3d-knoe-up:
@./scripts/k3d-knoe-up.sh
k3d-knoe-pf:
@./scripts/k3d-knoe-pf.sh
k3d-knoe-down:
@./scripts/k3d-knoe-down.sh
k8s/knoe/knoe-ekosystem-sql.yaml:
@echo "Generating ConfigMap from knoe-db/schema/ekosystem*.sql..."
@$(PYTHON) scripts/gen-ekosystem-configmap.py
@echo "✓ k8s/knoe/knoe-ekosystem-sql.yaml updated"
clean:
@echo "Cleaning build artifacts..."
rm -rf $(BUILD_DIR) $(DIST_DIR) *.spec
rm -rf __pycache__ knoe/__pycache__
@echo "✓ Clean complete"