Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
159 changes: 159 additions & 0 deletions .github/actions/kind/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
name: Kind cluster and Helm deploy
description: Create a Kind cluster with a local registry and install the general-simulation Helm chart

inputs:
namespace:
description: Kubernetes namespace for the release
required: false
default: general-simulation
helm_release:
description: Helm release name
required: false
default: general-simulation
registry:
description: Local registry host:port (Kind registry mirror)
required: false
default: localhost:5001
helm_extra_args:
description: Extra arguments passed to helm upgrade --install
required: false
default: ""
skip_image_build:
description: Skip building and pushing app images (use tags already in the local registry)
required: false
default: "false"
wait_for_rollout:
description: Wait for general-sim-api Deployment to become Available
required: false
default: "true"
run_builtin_smoke:
description: Run minimal /health check in this action (disable if the workflow runs kind-verify-deployment.sh)
required: false
default: "false"

runs:
using: composite
steps:
- name: Install Go (Kind CLI)
uses: actions/setup-go@v5
with:
go-version: "1.22.x"

- name: Install Kind
shell: bash
run: |
go install sigs.k8s.io/kind@v0.30.0
echo "$(go env GOPATH)/bin" >> "${GITHUB_PATH}"
- name: Install Podman
shell: bash
run: |
sudo apt-get update -qq
sudo apt-get install -y podman
podman version
podman info
- name: Create Kind cluster with local registry
shell: bash
env:
USE_PODMAN: "1"
run: bash ./scripts/ci/kind-with-registry.sh

- name: Install Helm
uses: azure/setup-helm@v4
with:
version: v3.19.4

- name: Helm dependencies
shell: bash
run: make helm-deps

- name: Build app images
if: inputs.skip_image_build != 'true'
shell: bash
run: make kind-build-images REGISTRY=${{ inputs.registry }}

- name: Push app images to local registry
if: inputs.skip_image_build != 'true'
shell: bash
run: make kind-push-images REGISTRY=${{ inputs.registry }} PUSH_EXTRA_ARGS=--tls-verify=false

- name: Create namespace
shell: bash
run: make k8s-namespace NAMESPACE=${{ inputs.namespace }}

- name: Helm install (Kind values)
id: helm_install
shell: bash
run: |
set -euo pipefail
make helm-install-kind \
NAMESPACE=${{ inputs.namespace }} \
HELM_RELEASE_NAME=${{ inputs.helm_release }} \
REGISTRY=${{ inputs.registry }} \
HELM_EXTRA_ARGS="${{ inputs.helm_extra_args }}"
- name: Dump cluster state on Helm install failure
if: failure() && steps.helm_install.outcome == 'failure'
shell: bash
run: |
set +e
NS="${{ inputs.namespace }}"
REL="${{ inputs.helm_release }}"
echo "=== kubectl get deploy,sts,svc,pvc,job,sa,pods -n ${NS} ==="
kubectl get deploy,sts,svc,pvc,job,sa,pods -n "${NS}" -o wide
echo "=== kubectl get events -n ${NS} (last 50) ==="
kubectl get events -n "${NS}" --sort-by=.lastTimestamp | tail -50
echo "=== StorageClasses ==="
kubectl get storageclass
echo "=== helm status ==="
helm status "${REL}" -n "${NS}" || true
dump_pod() {
local pod="$1"
echo "=== describe ${pod} ==="
kubectl describe -n "${NS}" "${pod}" | tail -50
kubectl logs -n "${NS}" "${pod}" --all-containers --tail=80 2>/dev/null || true
}
for dep in general-sim-api neo4j postgres bootstrap; do
echo "=== candidates matching *${dep}* ==="
kubectl get pods -n "${NS}" -o name 2>/dev/null | grep -i "${dep}" | while read -r pod; do
dump_pod "${pod}"
done
done
if kubectl get pod -n "${NS}" "${REL}-0" >/dev/null 2>&1; then
dump_pod "pod/${REL}-0"
fi
kubectl get jobs -n "${NS}" -o name 2>/dev/null | while read -r job; do
echo "=== job describe ${job} ==="
kubectl describe -n "${NS}" "${job}" | tail -40
kubectl logs -n "${NS}" "job/$(basename "${job}")" --all-containers --tail=80 2>/dev/null || true
done
- name: Wait for API deployment
if: inputs.wait_for_rollout == 'true'
shell: bash
run: |
kubectl wait --namespace "${{ inputs.namespace }}" \
--for=condition=available \
deployment/general-sim-api \
--timeout=300s
- name: Smoke test API /health
if: inputs.wait_for_rollout == 'true' && inputs.run_builtin_smoke == 'true'
shell: bash
run: |
set -euo pipefail
kubectl port-forward -n "${{ inputs.namespace }}" \
svc/general-sim-api 18000:8000 >/tmp/pf.log 2>&1 &
PF_PID=$!
trap 'kill "${PF_PID}" 2>/dev/null || true' EXIT
for _ in $(seq 1 45); do
if curl -sf http://127.0.0.1:18000/health | grep -q '"status"'; then
echo "API /health OK"
exit 0
fi
sleep 2
done
echo "API /health did not become ready"
cat /tmp/pf.log || true
exit 1
71 changes: 71 additions & 0 deletions .github/workflows/kind-helm-smoke.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Kind Helm smoke

# Helm lint, Kind deploy, and API verification (health + seed + /query with fake LLM).
on:
workflow_dispatch:
pull_request:
types: [opened, synchronize, reopened]
branches: [main, master, development]
paths:
- "apps/**"
- "lib/**"
- "domain/**"
- "deploy/**"
- "scripts/ci/**"
- "scripts/local-kind-smoke-test.sh"
- "scripts/seed_demo.py"
- "scripts/smoke-uk-closure.sh"
- "Makefile"
- ".github/actions/kind/**"
- ".github/workflows/kind-helm-smoke.yml"
push:
branches: [main, master, development]
paths:
- "apps/**"
- "lib/**"
- "domain/**"
- "deploy/**"
- "scripts/ci/**"
- "scripts/local-kind-smoke-test.sh"
- "scripts/seed_demo.py"
- "scripts/smoke-uk-closure.sh"
- "Makefile"
- ".github/actions/kind/**"
- ".github/workflows/kind-helm-smoke.yml"

concurrency:
group: kind-helm-smoke-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

env:
KIND_NAMESPACE: general-simulation
HELM_RELEASE: general-simulation

jobs:
kind-helm-smoke:
name: Helm lint, Kind deploy, API verify
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: azure/setup-helm@v4
with:
version: v3.19.4

- name: Helm chart lint
run: make lint-charts

- name: Deploy chart on Kind
uses: ./.github/actions/kind
with:
namespace: ${{ env.KIND_NAMESPACE }}
helm_release: ${{ env.HELM_RELEASE }}
registry: localhost:5001
run_builtin_smoke: "false"

- name: Verify deployment (health, seed, /query)
shell: bash
run: make kind-verify
env:
NAMESPACE: ${{ env.KIND_NAMESPACE }}
HELM_RELEASE_NAME: ${{ env.HELM_RELEASE }}
101 changes: 98 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,24 @@ IMG_NEO4J := $(REGISTRY)/$(NEO4J_IMAGE_NAME):$(TAG)

# ── Helm chart paths ──────────────────────────────────────────────────────────
CHART_UMBRELLA := deploy/helm
CHART_VALUES := deploy/helm/values.yaml
CHART_VALUES_KIND := deploy/helm/values-kind.yaml
CHART_VALUES_SECRETS := deploy/helm/values-secrets.yaml

# Common flags passed to every helm command
HELM_RELEASE_NAME ?= general-simulation
HELM_COMMON := --namespace $(NAMESPACE)
HELM_EXTRA_ARGS ?=
KIND_DEPLOY_TIMEOUT ?= 15m
# Optional on push, e.g. PUSH_EXTRA_ARGS=--tls-verify=false for Kind (localhost:5001)
PUSH_EXTRA_ARGS ?=
LOCAL_KIND_SMOKE_ARGS ?=

# Kind: pin images to the local registry via global.registry / neo4j.customImage.
HELM_KIND_IMAGE_SETS = \
--set global.registry=$(REGISTRY) \
--set global.imageTag=$(TAG) \
--set neo4j.image.customImage=$(IMG_NEO4J)

# Neo4j subchart reads image.customImage directly (not global.registry helpers).
_helm_neo4j_image_set := --set neo4j.image.customImage=$(IMG_NEO4J)
Expand Down Expand Up @@ -75,10 +88,13 @@ LOCAL_COMPOSE := deploy/local/composefile.yml
build build-postgres build-neo4j build-app \
deploy deploy-umbrella neo4j-connect \
package-chart \
undeploy status lint-charts test-unit smoke-test \
undeploy status lint-charts helm-deps test-unit smoke-test \
local-up local-down local-bootstrap \
kind-build-images kind-push-images k8s-namespace \
helm-install-kind kind-undeploy \
kind-preflight kind-verify local-kind-smoke-test \
_guard-values-secrets \
_guard-oc _guard-helm _guard-podman _guard-namespace \
_guard-oc _guard-helm _guard-podman _guard-namespace _guard-kubectl \
_remove-orphan-neo4j-resources _remove-openshift-routes

# ── Default target ────────────────────────────────────────────────────────────
Expand All @@ -95,11 +111,21 @@ help:
@printf " %-40s %s\n" "undeploy" "Uninstall Helm releases"
@printf " %-40s %s\n" "status" "helm list + oc get pods"
@printf " %-40s %s\n" "lint-charts" "helm lint"
@printf " %-40s %s\n" "helm-deps" "Update Helm chart dependencies"
@printf " %-40s %s\n" "test-unit" "Run unit tests (uv run pytest)"
@printf " %-40s %s\n" "smoke-test" "Seed UK demo + POST /query (auto cluster when deployed)"
@printf " %-40s %s\n" "local-up" "Start local Postgres + Neo4j (compose --wait)"
@printf " %-40s %s\n" "local-down" "Stop local Postgres + Neo4j"
@printf " %-40s %s\n" "local-bootstrap" "local-up + schema bootstrap (Postgres + Neo4j)"
@printf "\nKind / local Kubernetes:\n"
@printf " %-40s %s\n" "kind-preflight" "Check Podman VM / Kind node RAM before local smoke"
@printf " %-40s %s\n" "kind-build-images" "Build images for REGISTRY (default quay; use localhost:5001)"
@printf " %-40s %s\n" "kind-push-images" "Push kind-build-images to REGISTRY"
@printf " %-40s %s\n" "k8s-namespace" "Create kubectl namespace (NAMESPACE)"
@printf " %-40s %s\n" "helm-install-kind" "Install on Kind (values-kind.yaml + local REGISTRY)"
@printf " %-40s %s\n" "kind-verify" "Post-deploy checks (port-forward + /health + seed + /query)"
@printf " %-40s %s\n" "local-kind-smoke-test" "Full local Kind smoke (cluster + images + install + verify)"
@printf " %-40s %s\n" "kind-undeploy" "helm uninstall Kind release (kubectl; no oc)"
@printf "\nVariables:\n"
@printf " %-18s %s\n" "REGISTRY" "$(REGISTRY)"
@printf " %-18s %s\n" "APP_IMAGE_NAME" "$(APP_IMAGE_NAME)"
Expand Down Expand Up @@ -140,6 +166,10 @@ _guard-podman:
@command -v podman >/dev/null 2>&1 || \
{ echo "ERROR: 'podman' not found. Install Podman or substitute 'docker' by setting PODMAN=docker."; exit 1; }

_guard-kubectl:
@command -v kubectl >/dev/null 2>&1 || \
{ echo "ERROR: 'kubectl' not found. Install kubectl for Kind targets."; exit 1; }

# ── Container image builds ────────────────────────────────────────────────────
build: _guard-podman build-postgres build-neo4j build-app
@echo "==> All images built and pushed to $(REGISTRY)."
Expand Down Expand Up @@ -308,12 +338,15 @@ status: _guard-helm _guard-oc
@echo "==> Pod status:"
@oc get pods -n $(NAMESPACE)

lint-charts: _guard-helm
helm-deps: _guard-helm
@echo "==> Updating umbrella chart dependencies..."
helm repo add neo4j https://helm.neo4j.com/neo4j 2>/dev/null || true
helm repo update neo4j
helm repo add ai-architecture-charts $(LLM_SERVICE_CHART_REPO) 2>/dev/null || true
helm repo update ai-architecture-charts
helm dependency update $(CHART_UMBRELLA)

lint-charts: helm-deps
helm lint $(CHART_UMBRELLA)
@echo "==> Chart passed lint."

Expand All @@ -332,3 +365,65 @@ local-bootstrap: local-up
smoke-test:
@chmod +x scripts/smoke-uk-closure.sh
./scripts/smoke-uk-closure.sh

# ── Kind / plain Kubernetes ───────────────────────────────────────────────────

kind-build-images: _guard-podman
@echo "==> Building Neo4j image: $(IMG_NEO4J)"
podman build \
--platform=linux/amd64 \
-f deploy/container_files/neo4j/Containerfile \
-t $(IMG_NEO4J) \
deploy/container_files/neo4j
@echo "==> Building Postgres image: $(IMG_POSTGRES)"
podman build \
--platform=linux/amd64 \
-f deploy/container_files/postgres/Containerfile \
-t $(IMG_POSTGRES) \
deploy/container_files/postgres
@echo "==> Building FastAPI app image: $(IMG_APP)"
podman build \
--platform=linux/amd64 \
-f deploy/container_files/api/Containerfile \
-t $(IMG_APP) \
.

kind-push-images: _guard-podman
@echo "==> Pushing images to $(REGISTRY) ($(PUSH_EXTRA_ARGS))"
podman push $(PUSH_EXTRA_ARGS) $(IMG_NEO4J)
podman push $(PUSH_EXTRA_ARGS) $(IMG_POSTGRES)
podman push $(PUSH_EXTRA_ARGS) $(IMG_APP)

k8s-namespace: _guard-kubectl
@echo "==> Ensuring namespace $(NAMESPACE)"
kubectl create namespace $(NAMESPACE) --dry-run=client -o yaml | kubectl apply -f -
kubectl config set-context --current --namespace=$(NAMESPACE) >/dev/null 2>&1 || true

helm-install-kind: helm-deps k8s-namespace
@echo "==> Installing $(HELM_RELEASE_NAME) on Kind/Kubernetes (namespace: $(NAMESPACE), registry: $(REGISTRY))"
helm upgrade --install $(HELM_RELEASE_NAME) $(CHART_UMBRELLA) \
--namespace $(NAMESPACE) \
-f $(CHART_VALUES) \
-f $(CHART_VALUES_KIND) \
$(HELM_KIND_IMAGE_SETS) \
$(HELM_EXTRA_ARGS) \
--wait \
--timeout $(KIND_DEPLOY_TIMEOUT)

kind-undeploy: _guard-helm _guard-kubectl
@echo "==> Removing Helm release $(HELM_RELEASE_NAME) from namespace $(NAMESPACE)..."
helm uninstall $(HELM_RELEASE_NAME) --namespace $(NAMESPACE) 2>/dev/null || true

kind-preflight:
@chmod +x scripts/ci/kind-preflight.sh
@bash ./scripts/ci/kind-preflight.sh

kind-verify:
@chmod +x scripts/ci/kind-verify-deployment.sh
@NAMESPACE=$(NAMESPACE) HELM_RELEASE=$(HELM_RELEASE_NAME) \
bash ./scripts/ci/kind-verify-deployment.sh

local-kind-smoke-test:
@chmod +x scripts/local-kind-smoke-test.sh scripts/ci/kind-with-registry.sh \
scripts/ci/kind-preflight.sh scripts/ci/kind-verify-deployment.sh
@bash ./scripts/local-kind-smoke-test.sh $(LOCAL_KIND_SMOKE_ARGS)
Loading
Loading