From ac78aa819e2848f8235e67afbdef1be8d8108740 Mon Sep 17 00:00:00 2001 From: Andrew Holway Date: Fri, 27 Nov 2026 10:46:23 +0000 Subject: [PATCH 1/8] 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/8] 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/8] 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/8] 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/8] 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/8] 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' From 16c66a4a59fe2c3c124f03934cbdc707a9259d35 Mon Sep 17 00:00:00 2001 From: Andrew Holway Date: Fri, 27 Nov 2026 15:50:27 +0000 Subject: [PATCH 7/8] ci(gke): use a fixed admin/admin login for PR environments Removes the dependency on Secret Manager. Co-Authored-By: Claude Fable 5.2 --- .github/scripts/gke/README.md | 7 +++---- .github/scripts/gke/deploy.sh | 6 ++---- .github/scripts/gke/lib.sh | 2 +- .github/scripts/gke/pr-status.sh | 9 +++------ .github/scripts/gke/setup-gcp.sh | 14 +------------- .github/scripts/gke/smoke-test.sh | 5 +---- 6 files changed, 11 insertions(+), 32 deletions(-) diff --git a/.github/scripts/gke/README.md b/.github/scripts/gke/README.md index 782e77d..11cc839 100644 --- a/.github/scripts/gke/README.md +++ b/.github/scripts/gke/README.md @@ -9,7 +9,7 @@ stack is HAPI FHIR, OpenSearch and NiFi, deployed by |---|---| | Workflows | `.github/workflows/gke_deploy_test.yml`, `.github/workflows/gke_teardown.yml` | | 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 ` | +| Login | user `admin`, password `admin` | | Auth to Google Cloud | GitHub OIDC (Workload Identity Federation). No keys are stored anywhere. | ## How it works @@ -28,9 +28,8 @@ every script derives what it needs from the PR number. 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 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. +Every route asks for the same fixed login. Traefik passes it on, and the +OpenSearch `admin` user is given the same password, so one login opens all three. ## Teardown diff --git a/.github/scripts/gke/deploy.sh b/.github/scripts/gke/deploy.sh index ec8b53b..c7b5bc0 100755 --- a/.github/scripts/gke/deploy.sh +++ b/.github/scripts/gke/deploy.sh @@ -43,10 +43,8 @@ else fi log "Configuring basic auth" -password="$(gc secrets versions access latest --secret "$BASIC_AUTH_SECRET")" -[[ -n "${GITHUB_ACTIONS:-}" ]] && echo "::add-mask::${password}" kubectl -n traefik create secret generic basic-auth-users \ - --from-literal=users="${BASIC_AUTH_USER}:$(openssl passwd -apr1 "$password")" \ + --from-literal=users="${BASIC_AUTH_USER}:$(openssl passwd -apr1 "$BASIC_AUTH_PASSWORD")" \ --dry-run=client -o yaml | kubectl apply -f - log "Requesting the wildcard certificate for *.${DOMAIN}" @@ -57,7 +55,7 @@ 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" + "$BASIC_AUTH_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" diff --git a/.github/scripts/gke/lib.sh b/.github/scripts/gke/lib.sh index 9fdf672..4d0432b 100755 --- a/.github/scripts/gke/lib.sh +++ b/.github/scripts/gke/lib.sh @@ -22,7 +22,7 @@ export CLUSTER_LABEL="purpose=pr-deploy-test" # 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 BASIC_AUTH_PASSWORD="admin" # The namespace minimum_deployment.sh deploys to. NAMESPACE="$(source ../../../deployment/env/general.env && echo "$KUBE_NAMESPACE")" diff --git a/.github/scripts/gke/pr-status.sh b/.github/scripts/gke/pr-status.sh index ee1d1b3..fa17259 100755 --- a/.github/scripts/gke/pr-status.sh +++ b/.github/scripts/gke/pr-status.sh @@ -6,7 +6,7 @@ # Usage: pr-status.sh # live probes every app over public HTTPS and shows a dot per app # the others only change the headline -# Needs GH_TOKEN, and GH_REPO or GITHUB_REPOSITORY. "live" also needs gcloud. +# Needs GH_TOKEN, and GH_REPO or GITHUB_REPOSITORY. set -uo pipefail cd "$(dirname "$0")" || exit 1 source ./lib.sh @@ -59,15 +59,13 @@ app_title() { echo "Updated ${now}${run_link}" ;; live) - password="$(gc secrets versions access latest --secret "$BASIC_AUTH_SECRET")" - [[ -n "${GITHUB_ACTIONS:-}" ]] && echo "::add-mask::${password}" >&2 rows="" down=0 total=0 for app in $APPS; do name="${app%%:*}" url="https://${name}.${DOMAIN}${app#*:}" - code="$(curl -s -L -o /dev/null -m 20 -w '%{http_code}' -u "${BASIC_AUTH_USER}:${password}" "$url" || true)" + code="$(curl -s -L -o /dev/null -m 20 -w '%{http_code}' -u "${BASIC_AUTH_USER}:${BASIC_AUTH_PASSWORD}" "$url" || true)" total=$((total + 1)) if [[ "$code" =~ ^2 ]]; then dot="🟢" @@ -87,8 +85,7 @@ app_title() { echo "|---|---|---|" printf '%s' "$rows" echo - echo "**Sign in** with user \`${BASIC_AUTH_USER}\`. Get the password with:" - echo "\`gcloud secrets versions access latest --secret ${BASIC_AUTH_SECRET} --project ${GCP_PROJECT_ID}\`" + echo "**Sign in** with user \`${BASIC_AUTH_USER}\` and password \`${BASIC_AUTH_PASSWORD}\`." echo echo "Commit \`${commit}\` · checked ${now} · removed when the PR closes or after ${MAX_AGE_HOURS:-24} hours${run_link}" ;; diff --git a/.github/scripts/gke/setup-gcp.sh b/.github/scripts/gke/setup-gcp.sh index edc8ada..81acd36 100755 --- a/.github/scripts/gke/setup-gcp.sh +++ b/.github/scripts/gke/setup-gcp.sh @@ -25,7 +25,6 @@ POOL="github" PROVIDER="github" CI_SA="gha-deploy-test@${PROJECT_ID}.iam.gserviceaccount.com" NODE_SA="gke-node@${PROJECT_ID}.iam.gserviceaccount.com" -SECRET="preview-basic-auth-password" gc() { gcloud --project "$PROJECT_ID" --quiet "$@"; } log() { echo "==> $*" >&2; } @@ -61,7 +60,7 @@ PROJECT_NUMBER="$(gcloud projects describe "$PROJECT_ID" --format='value(project log "Enabling APIs" gc services enable container.googleapis.com compute.googleapis.com dns.googleapis.com \ iam.googleapis.com iamcredentials.googleapis.com sts.googleapis.com \ - secretmanager.googleapis.com cloudresourcemanager.googleapis.com + cloudresourcemanager.googleapis.com log "DNS zone for $BASE_DOMAIN" gc dns managed-zones describe "$DNS_ZONE_NAME" >/dev/null 2>&1 || @@ -101,14 +100,6 @@ fi gc iam service-accounts add-iam-policy-binding "$CI_SA" --role roles/iam.workloadIdentityUser \ --member "principalSet://iam.googleapis.com/projects/${PROJECT_NUMBER}/locations/global/workloadIdentityPools/${POOL}/*" >/dev/null -log "Basic auth password" -if ! gc secrets describe "$SECRET" >/dev/null 2>&1; then - gc secrets create "$SECRET" --replication-policy automatic >/dev/null - openssl rand -hex 16 | tr -d '\n' | gc secrets versions add "$SECRET" --data-file=- >/dev/null -fi -gc secrets add-iam-policy-binding "$SECRET" --member "serviceAccount:${CI_SA}" \ - --role roles/secretmanager.secretAccessor >/dev/null - # cert-manager in every PR cluster proves domain ownership by writing DNS records. # The Kubernetes identity pool only exists once the project has had a cluster. log "cert-manager DNS access" @@ -131,7 +122,4 @@ $(for repo in "$@"; do echo " gh variable set GCP_WORKLOAD_IDENTITY_PROVIDER -R ${repo} -b ${provider_name}" echo " gh variable set GCP_SERVICE_ACCOUNT -R ${repo} -b ${CI_SA}" done) - -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/smoke-test.sh b/.github/scripts/gke/smoke-test.sh index 9753465..f09b0c4 100755 --- a/.github/scripts/gke/smoke-test.sh +++ b/.github/scripts/gke/smoke-test.sh @@ -7,9 +7,6 @@ cd "$(dirname "$0")" source ./lib.sh set_pr "${1:?usage: smoke-test.sh }" -password="$(gc secrets versions access latest --secret "$BASIC_AUTH_SECRET")" -[[ -n "${GITHUB_ACTIONS:-}" ]] && echo "::add-mask::${password}" - status() { curl -sS -o /dev/null -m 20 -w '%{http_code}' "$@" || true; } failed=0 @@ -19,7 +16,7 @@ for app in $APPS; do # New DNS names and certificates take a little while to be visible everywhere. for _ in $(seq 1 30); do anon="$(status "$url")" - authed="$(status -L -u "${BASIC_AUTH_USER}:${password}" "$url")" + authed="$(status -L -u "${BASIC_AUTH_USER}:${BASIC_AUTH_PASSWORD}" "$url")" if [[ "$anon" == "401" && "$authed" =~ ^2 ]]; then ok=1 break From 4a16e46de58ecb63acd7516e2e66131dec879c8a Mon Sep 17 00:00:00 2001 From: Andrew Holway Date: Fri, 27 Nov 2026 15:50:27 +0000 Subject: [PATCH 8/8] ci(gke): add a script that doubles the quotas PR environments use Co-Authored-By: Claude Fable 5.2 --- .github/scripts/gke/raise-quotas.sh | 82 +++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100755 .github/scripts/gke/raise-quotas.sh diff --git a/.github/scripts/gke/raise-quotas.sh b/.github/scripts/gke/raise-quotas.sh new file mode 100755 index 0000000..02b16d1 --- /dev/null +++ b/.github/scripts/gke/raise-quotas.sh @@ -0,0 +1,82 @@ +#!/usr/bin/env bash +# Ask Google to double the quotas that limit how many PR environments the GKE +# deployment test can run at once. Run it by hand as a project owner; CI never +# runs this. +# +# Usage: raise-quotas.sh +# +# Each quota's current limit is read from the project and a request is filed for +# twice that, so every run doubles again. An increase is a request: Google +# grants it at once or reviews it first. See what happened with: +# +# gcloud quotas preferences list --project +# +# Environment: +# GCP_PROJECT_ID project to change (default cogstack-platform-ci) +# GCP_ZONE zone the PR clusters run in (default europe-west2-a) +# QUOTA_CONTACT_EMAIL address Google writes to about the request; Google +# refuses an increase without one (default +# andrew@cogstack.org). Its Google account must be +# allowed to change quotas on the project. +# DRY_RUN=1 validate the requests without filing them +# +# Commands: https://docs.cloud.google.com/docs/quotas/gcloud-cli-examples +# Requirements: gcloud, jq. +set -euo pipefail + +QUOTA_CONTACT_EMAIL="${QUOTA_CONTACT_EMAIL:-andrew@cogstack.org}" + +PROJECT_ID="${GCP_PROJECT_ID:-cogstack-platform-ci}" +ZONE="${GCP_ZONE:-europe-west2-a}" +REGION="${ZONE%-*}" + +# +# One PR environment is a zonal cluster of two e2-standard-4 nodes, with SSD +# boot disks and volumes and a load balancer. +QUOTAS=" +compute.googleapis.com SSD-TOTAL-GB-per-project-region region=$REGION +compute.googleapis.com CPUS-ALL-REGIONS-per-project - +compute.googleapis.com IN-USE-ADDRESSES-per-project-region region=$REGION +container.googleapis.com ClustersPerZone zone=$ZONE +" + +log() { echo "==> $*" >&2; } + +# current_limit : the limit set for that +# dimension, or the quota's default where the project has none of its own. +current_limit() { + local key="${3%%=*}" value="${3#*=}" + gcloud quotas info describe "$2" --service "$1" --project "$PROJECT_ID" --format json | + jq -r --arg key "$key" --arg value "$value" ' + .dimensionsInfos + | (map(select(.dimensions[$key]? == $value)) + map(select((.dimensions // {}) == {}))) + | .[0].details.value // empty' +} + +extra=(--email "$QUOTA_CONTACT_EMAIL") +[[ -n "${DRY_RUN:-}" ]] && extra+=(--validate-only) + +while read -r service quota dimension; do + [[ -n "$service" ]] || continue + limit="$(current_limit "$service" "$quota" "$dimension")" + if ! [[ "$limit" =~ ^[0-9]+$ ]]; then + echo "Could not read the current limit of $quota (got '$limit')" >&2 + exit 1 + fi + + args=() + id="pr-environments-${quota}" + if [[ "$dimension" != "-" ]]; then + args+=(--dimensions "$dimension") + id+="-${dimension#*=}" + fi + + log "$quota ${dimension/#-/}: $limit -> $((limit * 2))" + # "update --allow-missing" creates the request, or changes the one an earlier + # run filed under the same ID. + gcloud quotas preferences update "$(tr '[:upper:]' '[:lower:]' <<< "$id")" \ + --service "$service" --project "$PROJECT_ID" \ + --quota-id "$quota" --preferred-value "$((limit * 2))" \ + --justification "More concurrent per-pull-request GKE test environments" \ + --allow-missing ${args[@]+"${args[@]}"} ${extra[@]+"${extra[@]}"} +done <<< "$QUOTAS"