From ac78aa819e2848f8235e67afbdef1be8d8108740 Mon Sep 17 00:00:00 2001 From: Andrew Holway Date: Fri, 27 Nov 2026 10:46:23 +0000 Subject: [PATCH 1/6] chore(hapi-fhir): bump FHIR database image to postgres:18.6-trixie Co-Authored-By: Claude Fable 5.2 --- deployment/charts/hapi-fhir/README.md | 2 +- deployment/charts/hapi-fhir/templates/postgres.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/deployment/charts/hapi-fhir/README.md b/deployment/charts/hapi-fhir/README.md index e7bc729..b06ec77 100644 --- a/deployment/charts/hapi-fhir/README.md +++ b/deployment/charts/hapi-fhir/README.md @@ -8,7 +8,7 @@ PostgreSQL, so a search straight after a write still sees it. | Workload | Image | Service | Storage | | --- | --- | --- | --- | | `hapi-fhir` | `hapiproject/hapi:v8.12.0-2` | `hapi-fhir:8080` | none | -| `hapi-fhir-db` | `postgres:16-alpine` | `hapi-fhir-db:5432` | 10Gi PVC | +| `hapi-fhir-db` | `postgres:18.6-trixie` | `hapi-fhir-db:5432` | 10Gi PVC | | `hapi-fhir-opensearch` | `opensearchproject/opensearch:3.9.0` | `hapi-fhir-opensearch:9200` | 10Gi PVC | ## No templating diff --git a/deployment/charts/hapi-fhir/templates/postgres.yaml b/deployment/charts/hapi-fhir/templates/postgres.yaml index bbfcd24..b0e0aef 100644 --- a/deployment/charts/hapi-fhir/templates/postgres.yaml +++ b/deployment/charts/hapi-fhir/templates/postgres.yaml @@ -29,7 +29,7 @@ spec: spec: containers: - name: postgres - image: postgres:16-alpine + image: postgres:18.6-trixie # Modest tuning for a single small node. args: - -c From 25dbd0afcfaf947dc2174595c7cd76b3887eb4f0 Mon Sep 17 00:00:00 2001 From: Andrew Holway Date: Fri, 27 Nov 2026 12:12:19 +0000 Subject: [PATCH 2/6] feat(deployment): publish the minimum stack through an ingress when INGRESS_DOMAIN is set Co-Authored-By: Claude Fable 5.2 --- deployment/scripts/minimum_deployment.sh | 41 +++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/deployment/scripts/minimum_deployment.sh b/deployment/scripts/minimum_deployment.sh index 7441d4f..298bec6 100755 --- a/deployment/scripts/minimum_deployment.sh +++ b/deployment/scripts/minimum_deployment.sh @@ -12,6 +12,11 @@ # that are missing. OpenSearch users and their passwords come from # deployment/env/authentication.env. # +# Set INGRESS_DOMAIN to publish the three services through the cluster's default +# ingress controller, at hapi., opensearch. and nifi.: +# +# INGRESS_DOMAIN=example.org bash deployment/scripts/minimum_deployment.sh +# # Requirements: kubectl, helm, openssl, htpasswd. set -euo pipefail @@ -71,7 +76,41 @@ kubectl -n "$ns" apply -f rendered/opensearch.yaml helm template cogstack-nifi charts/nifi > rendered/nifi.yaml kubectl -n "$ns" apply -f rendered/nifi.yaml -# --- 3. Status ----------------------------------------------------------------- +# --- 3. Ingress ---------------------------------------------------------------- +# HAPI FHIR and NiFi have no login of their own, so the ingress controller must +# add one if the address is public. Where NetworkPolicy is enforced, NiFi's +# policy admits only NGINX pods and the nifi host will not answer. +ingress() { # ingress + cat < rendered/ingress.yaml + kubectl -n "$ns" apply -f rendered/ingress.yaml +fi + +# --- 4. Status ----------------------------------------------------------------- kubectl -n "$ns" get pods cat < Date: Fri, 27 Nov 2026 12:12:41 +0000 Subject: [PATCH 3/6] ci(gke): deploy the minimum stack to PR environments with minimum_deployment.sh Replaces the cogstack-ce-helm install. PR environments now hold HAPI FHIR, OpenSearch and NiFi at .pr-.platform.cogstack.dev. Co-Authored-By: Claude Fable 5.2 --- .github/scripts/gke/README.md | 26 ++++++---- .github/scripts/gke/cluster-up.sh | 1 + .github/scripts/gke/deploy.sh | 33 ++++++------ .github/scripts/gke/lib.sh | 12 +++-- .github/scripts/gke/node-config.yaml | 5 ++ .github/scripts/gke/platform.tmpl.yaml | 4 +- .github/scripts/gke/pr-status.sh | 9 ++-- .github/scripts/gke/setup-gcp.sh | 2 +- .github/scripts/gke/teardown.sh | 3 +- .github/scripts/gke/values.tmpl.yaml | 69 -------------------------- .github/workflows/gke_deploy_test.yml | 15 +++--- 11 files changed, 58 insertions(+), 121 deletions(-) create mode 100644 .github/scripts/gke/node-config.yaml delete mode 100644 .github/scripts/gke/values.tmpl.yaml diff --git a/.github/scripts/gke/README.md b/.github/scripts/gke/README.md index ab22b4d..782e77d 100644 --- a/.github/scripts/gke/README.md +++ b/.github/scripts/gke/README.md @@ -1,13 +1,15 @@ # GKE deployment test -Every pull request that touches the Helm charts is deployed to its own small GKE -cluster and left running, so reviewers can open the apps in a browser. +Every pull request that touches the deployment is deployed to its own small GKE +cluster and left running, so reviewers can open the services in a browser. The +stack is HAPI FHIR, OpenSearch and NiFi, deployed by +`deployment/scripts/minimum_deployment.sh` and nothing else. | | | |---|---| | Workflows | `.github/workflows/gke_deploy_test.yml`, `.github/workflows/gke_teardown.yml` | -| URLs | `https://.pr-.platform.cogstack.dev` for `trainer`, `jupyter`, `dashboards`, `medcat`, `anoncat`, `ocr` | -| Login | user `cogstack`; password: `gcloud secrets versions access latest --secret preview-basic-auth-password --project ` | +| URLs | `https://.pr-.platform.cogstack.dev` for `hapi`, `opensearch`, `nifi` | +| Login | user `admin`; password: `gcloud secrets versions access latest --secret preview-basic-auth-password --project ` | | Auth to Google Cloud | GitHub OIDC (Workload Identity Federation). No keys are stored anywhere. | ## How it works @@ -17,16 +19,18 @@ every script derives what it needs from the PR number. 1. `cluster-up.sh` creates the cluster, or reuses it if a previous push already did. 2. `deploy.sh` installs Traefik and cert-manager, points `*.pr-.platform.cogstack.dev` - at the load balancer, obtains a wildcard certificate, then installs or upgrades - `cogstack-ce-helm` (`deployment/charts/ce`) from the PR and runs `helm test`. -3. `smoke-test.sh` requests every app over public HTTPS. + at the load balancer, obtains a wildcard certificate, then runs + `minimum_deployment.sh` from the PR with `INGRESS_DOMAIN` set and waits for + the workloads. +3. `smoke-test.sh` requests every service over public HTTPS. 4. `pr-status.sh` writes a panel at the top of the PR description: a link and a green or red dot per app. It shows "deploying", "failed" and "removed" too, and the hourly job re-checks the dots for environments that are still up. 5. The check goes green and the cluster stays up. -Every route sits behind basic auth, because the charts ship demo passwords and -the URLs are public. +Every route sits behind basic auth, because HAPI FHIR and NiFi have no login +and the URLs are public. Traefik passes the login on, and the OpenSearch `admin` +user is given the same password, so one login opens all three. ## Teardown @@ -66,6 +70,6 @@ To move the test to another repository: ## Limits - Pull requests from forks and from Dependabot are skipped: they cannot obtain an OIDC token. -- Pull requests that change nothing under `deployment/charts/`, `.github/scripts/` or - `.github/workflows/gke_*` are not deployed; the check is skipped and counts as passing. +- Pull requests that change nothing under `deployment/charts/`, `deployment/scripts/`, + `deployment/env/`, `.github/scripts/` or `.github/workflows/gke_*` are not deployed; the check is skipped and counts as passing. - The charts deploy published images, so this tests the charts, not unreleased application code. diff --git a/.github/scripts/gke/cluster-up.sh b/.github/scripts/gke/cluster-up.sh index ce0f8d8..2b968d7 100755 --- a/.github/scripts/gke/cluster-up.sh +++ b/.github/scripts/gke/cluster-up.sh @@ -19,6 +19,7 @@ case "$status" in --disk-size 50 \ --service-account "$NODE_SERVICE_ACCOUNT" \ --workload-pool "${GCP_PROJECT_ID}.svc.id.goog" \ + --system-config-from-file node-config.yaml \ --labels "${CLUSTER_LABEL},pr=${PR_NUMBER}" ;; RUNNING | RECONCILING) diff --git a/.github/scripts/gke/deploy.sh b/.github/scripts/gke/deploy.sh index 37d08b8..ec8b53b 100755 --- a/.github/scripts/gke/deploy.sh +++ b/.github/scripts/gke/deploy.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash -# Deploy this checkout of cogstack-ce-helm to the PR's cluster, behind HTTPS. -# Safe to re-run: a later push to the PR upgrades the existing release. +# Deploy this checkout's minimum stack (HAPI FHIR, OpenSearch, NiFi) to the PR's +# cluster, behind HTTPS, with deployment/scripts/minimum_deployment.sh. +# Safe to re-run: a later push to the PR applies the manifests again. # Usage: deploy.sh (run cluster-up.sh first) set -euo pipefail cd "$(dirname "$0")" @@ -52,21 +53,15 @@ log "Requesting the wildcard certificate for *.${DOMAIN}" envsubst '${GCP_PROJECT_ID} ${DOMAIN}' < platform.tmpl.yaml | kubectl apply -f - kubectl -n traefik wait --for=condition=Ready certificate/wildcard --timeout=15m -log "Deploying cogstack-ce-helm" -envsubst '${DOMAIN}' < values.tmpl.yaml > "$WORK/values.yaml" -(cd "$REPO_ROOT/deployment/charts" && "$REPO_ROOT/.github/scripts/helm-recursive-dependency-update.py") +log "Deploying the minimum stack" +# The script takes its OpenSearch users from this file instead of the passwords +# committed in deployment/env/authentication.env. +printf 'OPENSEARCH_ADMIN_PASSWORD=%s\nOPENSEARCH_KIBANA_PASSWORD=%s\n' \ + "$password" "$(openssl rand -hex 16)" > "$WORK/authentication.env" +OPENSEARCH_AUTH_FILE="$WORK/authentication.env" INGRESS_DOMAIN="$DOMAIN" \ + bash "$REPO_ROOT/deployment/scripts/minimum_deployment.sh" -# A release left failed or half-applied by an earlier run blocks upgrades; start it clean. -release_status="$(helm status "$RELEASE_NAME" -n "$RELEASE_NAMESPACE" -o json 2>/dev/null | jq -r '.info.status' || true)" -if [[ -n "$release_status" && "$release_status" != "deployed" ]]; then - log "Release is '$release_status'; uninstalling before reinstall" - helm uninstall "$RELEASE_NAME" -n "$RELEASE_NAMESPACE" --wait --timeout 10m -fi - -helm upgrade --install "$RELEASE_NAME" "$REPO_ROOT/deployment/charts/ce" \ - --namespace "$RELEASE_NAMESPACE" --create-namespace \ - -f "$WORK/values.yaml" \ - --wait --timeout 30m - -log "Running helm tests" -helm test "$RELEASE_NAME" -n "$RELEASE_NAMESPACE" --logs --timeout 15m +log "Waiting for the workloads" +for workload in $(kubectl -n "$NAMESPACE" get deployment,statefulset -o name); do + kubectl -n "$NAMESPACE" rollout status "$workload" --timeout=20m +done diff --git a/.github/scripts/gke/lib.sh b/.github/scripts/gke/lib.sh index 2a76849..9fdf672 100755 --- a/.github/scripts/gke/lib.sh +++ b/.github/scripts/gke/lib.sh @@ -18,11 +18,15 @@ export NODE_SERVICE_ACCOUNT="gke-node@${GCP_PROJECT_ID}.iam.gserviceaccount.com" # Label carried by every cluster this test creates; the reaper selects on it. export CLUSTER_LABEL="purpose=pr-deploy-test" -export BASIC_AUTH_USER="cogstack" +# Traefik asks for this login on every route and passes it on, and deploy.sh +# gives the same password to the OpenSearch user of the same name. One login +# therefore opens all three services. +export BASIC_AUTH_USER="admin" export BASIC_AUTH_SECRET="preview-basic-auth-password" -export RELEASE_NAME="cogstack" -export RELEASE_NAMESPACE="cogstack" +# The namespace minimum_deployment.sh deploys to. +NAMESPACE="$(source ../../../deployment/env/general.env && echo "$KUBE_NAMESPACE")" +export NAMESPACE # Pinned so that an upstream chart release cannot break a required check. export TRAEFIK_CHART_VERSION="42.4.1" @@ -30,7 +34,7 @@ export CERT_MANAGER_CHART_VERSION="v1.21.3" # Apps exposed per PR as .pr-., with the path the # smoke test requests. -export APPS="trainer:/ jupyter:/ dashboards:/ medcat:/api/health/live anoncat:/api/health/live ocr:/api/health" +export APPS="hapi:/fhir/metadata opensearch:/ nifi:/nifi/" # set_pr : derive the per-PR names. set_pr() { diff --git a/.github/scripts/gke/node-config.yaml b/.github/scripts/gke/node-config.yaml new file mode 100644 index 0000000..f77d32d --- /dev/null +++ b/.github/scripts/gke/node-config.yaml @@ -0,0 +1,5 @@ +# GKE node settings for PR clusters. OpenSearch refuses to start with the +# default vm.max_map_count of 65530. +linuxConfig: + sysctl: + vm.max_map_count: 262144 diff --git a/.github/scripts/gke/platform.tmpl.yaml b/.github/scripts/gke/platform.tmpl.yaml index 56ffea1..1fa492a 100644 --- a/.github/scripts/gke/platform.tmpl.yaml +++ b/.github/scripts/gke/platform.tmpl.yaml @@ -36,5 +36,5 @@ metadata: spec: basicAuth: secret: basic-auth-users - # Do not pass the browser's Basic credentials on to the apps. - removeHeader: true + # OpenSearch needs the credentials too; see BASIC_AUTH_USER in lib.sh. + removeHeader: false diff --git a/.github/scripts/gke/pr-status.sh b/.github/scripts/gke/pr-status.sh index 38acc2f..ee1d1b3 100755 --- a/.github/scripts/gke/pr-status.sh +++ b/.github/scripts/gke/pr-status.sh @@ -27,12 +27,9 @@ now="$(date -u '+%Y-%m-%d %H:%M UTC')" app_title() { case "$1" in - trainer) echo "MedCAT Trainer" ;; - jupyter) echo "JupyterHub" ;; - dashboards) echo "OpenSearch Dashboards" ;; - medcat) echo "MedCAT Service (API)" ;; - anoncat) echo "AnonCAT Service (API)" ;; - ocr) echo "OCR Service (API)" ;; + hapi) echo "HAPI FHIR (API)" ;; + opensearch) echo "OpenSearch (API)" ;; + nifi) echo "NiFi" ;; *) echo "$1" ;; esac } diff --git a/.github/scripts/gke/setup-gcp.sh b/.github/scripts/gke/setup-gcp.sh index 18a820f..edc8ada 100755 --- a/.github/scripts/gke/setup-gcp.sh +++ b/.github/scripts/gke/setup-gcp.sh @@ -132,6 +132,6 @@ $(for repo in "$@"; do echo " gh variable set GCP_SERVICE_ACCOUNT -R ${repo} -b ${CI_SA}" done) -3. Password for the PR environments (user "cogstack"): +3. Password for the PR environments (user "admin"): gcloud secrets versions access latest --secret ${SECRET} --project ${PROJECT_ID} EOF diff --git a/.github/scripts/gke/teardown.sh b/.github/scripts/gke/teardown.sh index 04cd1e6..d1c79f6 100755 --- a/.github/scripts/gke/teardown.sh +++ b/.github/scripts/gke/teardown.sh @@ -13,8 +13,7 @@ if [[ -n "$status" ]]; then # cluster alone leaves the load balancer and the volume disks behind, billing. if [[ "$status" == "RUNNING" || "$status" == "RECONCILING" ]] && get_credentials; then log "Removing workloads, volumes and the load balancer" - helm uninstall "$RELEASE_NAME" -n "$RELEASE_NAMESPACE" --wait --timeout 10m || true - kubectl delete namespace "$RELEASE_NAMESPACE" --ignore-not-found --timeout=10m || true + kubectl delete namespace "$NAMESPACE" --ignore-not-found --timeout=10m || true helm uninstall traefik -n traefik --wait --timeout 10m || true kubectl -n traefik delete svc --all --ignore-not-found --timeout=10m || true else diff --git a/.github/scripts/gke/values.tmpl.yaml b/.github/scripts/gke/values.tmpl.yaml deleted file mode 100644 index f630062..0000000 --- a/.github/scripts/gke/values.tmpl.yaml +++ /dev/null @@ -1,69 +0,0 @@ -# Values for cogstack-ce-helm in a PR environment: the chart defaults plus an -# ingress per app. Rendered with envsubst; ${DOMAIN} is pr-.. -opensearch: - replicas: 1 - # GKE nodes ship vm.max_map_count=65530; OpenSearch refuses to start below 262144. - sysctlInit: - enabled: true - -opensearch-dashboards: - ingress: - enabled: true - ingressClassName: traefik - hosts: - - host: dashboards.${DOMAIN} - paths: - - path: / - backend: - serviceName: "" - servicePort: "" - -medcat-service: - ingress: - enabled: true - className: traefik - hosts: - - host: medcat.${DOMAIN} - paths: - - path: / - pathType: Prefix - -anoncat-service: - ingress: - enabled: true - className: traefik - hosts: - - host: anoncat.${DOMAIN} - paths: - - path: / - pathType: Prefix - -ocr-service: - ingress: - enabled: true - className: traefik - hosts: - - host: ocr.${DOMAIN} - paths: - - path: / - pathType: Prefix - -medcat-trainer: - env: - CSRF_TRUSTED_ORIGINS: "https://trainer.${DOMAIN}" - ingress: - enabled: true - className: traefik - hosts: - - host: trainer.${DOMAIN} - paths: - - path: / - pathType: Prefix - -cogstack-jupyterhub: - jupyterhub: - ingress: - enabled: true - ingressClassName: traefik - hosts: - - jupyter.${DOMAIN} diff --git a/.github/workflows/gke_deploy_test.yml b/.github/workflows/gke_deploy_test.yml index db7712e..4dafe6a 100644 --- a/.github/workflows/gke_deploy_test.yml +++ b/.github/workflows/gke_deploy_test.yml @@ -1,8 +1,9 @@ -# Deploy the PR's cogstack-ce-helm chart to its own GKE cluster and leave it -# running at https://.pr-.platform.cogstack.dev for review. The -# links and a status dot per app are kept at the top of the PR description. +# Deploy the PR's minimum stack (HAPI FHIR, OpenSearch, NiFi) to its own GKE +# cluster with deployment/scripts/minimum_deployment.sh and leave it running at +# https://.pr-.platform.cogstack.dev for review. The links and +# a status dot per service are kept at the top of the PR description. # -# - The first run for a PR creates the cluster; later pushes upgrade the release. +# - The first run for a PR creates the cluster; later pushes apply the manifests again. # - The cluster is removed by gke_teardown.yml (PR closed, manual, or too old). # - Authentication to Google Cloud is GitHub OIDC; there are no stored keys. # - Nothing here names a repository. The test runs wherever the three GCP_* @@ -46,7 +47,7 @@ jobs: PR_NUMBER: ${{ github.event.pull_request.number }} run: | if gh api "repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}/files" --paginate --jq '.[].filename' | - grep -qE '^(deployment/charts/|\.github/scripts/|\.github/workflows/gke_)'; then + grep -qE '^(deployment/(charts|scripts|env)/|\.github/scripts/|\.github/workflows/gke_)'; then echo "deploy=true" >> "$GITHUB_OUTPUT" else echo "deploy=false" >> "$GITHUB_OUTPUT" @@ -90,8 +91,8 @@ jobs: with: version: v3.17.0 - - name: Install Python deps for chart scripts - run: pip install pyyaml + - name: Install htpasswd + run: command -v htpasswd || { sudo apt-get update && sudo apt-get install -y apache2-utils; } - name: Create or reuse the cluster run: .github/scripts/gke/cluster-up.sh "$PR_NUMBER" From 6dd63fc9387f076a5828bd4a96671199852ec14a Mon Sep 17 00:00:00 2001 From: Andrew Holway Date: Fri, 27 Nov 2026 12:21:46 +0000 Subject: [PATCH 4/6] empty From 03d8e23120c4ce089ef89da1a55aef91bfbbb1de Mon Sep 17 00:00:00 2001 From: Andrew Holway Date: Fri, 27 Nov 2026 12:23:33 +0000 Subject: [PATCH 5/6] ci(gke): do not set vm.max_map_count on PR cluster nodes Co-Authored-By: Claude Fable 5.2 --- .github/scripts/gke/cluster-up.sh | 1 - .github/scripts/gke/node-config.yaml | 5 ----- 2 files changed, 6 deletions(-) delete mode 100644 .github/scripts/gke/node-config.yaml diff --git a/.github/scripts/gke/cluster-up.sh b/.github/scripts/gke/cluster-up.sh index 2b968d7..ce0f8d8 100755 --- a/.github/scripts/gke/cluster-up.sh +++ b/.github/scripts/gke/cluster-up.sh @@ -19,7 +19,6 @@ case "$status" in --disk-size 50 \ --service-account "$NODE_SERVICE_ACCOUNT" \ --workload-pool "${GCP_PROJECT_ID}.svc.id.goog" \ - --system-config-from-file node-config.yaml \ --labels "${CLUSTER_LABEL},pr=${PR_NUMBER}" ;; RUNNING | RECONCILING) diff --git a/.github/scripts/gke/node-config.yaml b/.github/scripts/gke/node-config.yaml deleted file mode 100644 index f77d32d..0000000 --- a/.github/scripts/gke/node-config.yaml +++ /dev/null @@ -1,5 +0,0 @@ -# GKE node settings for PR clusters. OpenSearch refuses to start with the -# default vm.max_map_count of 65530. -linuxConfig: - sysctl: - vm.max_map_count: 262144 From f81f8f16d0e503ed3d5f68f874283cf1dacbb7ee Mon Sep 17 00:00:00 2001 From: Andrew Holway Date: Fri, 27 Nov 2026 13:19:34 +0000 Subject: [PATCH 6/6] ci(gke): raise vm.max_map_count on PR cluster nodes Co-Authored-By: Claude Fable 5.2 --- .github/scripts/gke/cluster-up.sh | 1 + .github/scripts/gke/node-config.yaml | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100644 .github/scripts/gke/node-config.yaml diff --git a/.github/scripts/gke/cluster-up.sh b/.github/scripts/gke/cluster-up.sh index ce0f8d8..2b968d7 100755 --- a/.github/scripts/gke/cluster-up.sh +++ b/.github/scripts/gke/cluster-up.sh @@ -19,6 +19,7 @@ case "$status" in --disk-size 50 \ --service-account "$NODE_SERVICE_ACCOUNT" \ --workload-pool "${GCP_PROJECT_ID}.svc.id.goog" \ + --system-config-from-file node-config.yaml \ --labels "${CLUSTER_LABEL},pr=${PR_NUMBER}" ;; RUNNING | RECONCILING) diff --git a/.github/scripts/gke/node-config.yaml b/.github/scripts/gke/node-config.yaml new file mode 100644 index 0000000..6c9ecf2 --- /dev/null +++ b/.github/scripts/gke/node-config.yaml @@ -0,0 +1,9 @@ +# Node system configuration for PR clusters, passed to +# `gcloud container clusters create --system-config-from-file`. +# https://docs.cloud.google.com/kubernetes-engine/docs/how-to/node-system-config +# +# OpenSearch refuses to start below 262144; GKE nodes default to 65530. +# GKE accepts 65536 to 2147483647, and the value must be a string. +linuxConfig: + sysctl: + vm.max_map_count: '262144'