Skip to content

Phase 7 — End-to-End Validation and What the Pipeline Revealed

Phase 6 built a five-job GitHub Actions CI/CD pipeline — tests, security scan, multi-architecture image build, GitOps manifest update, ArgoCD sync. Everything verified. All jobs green.

Then I used it for the first time to deploy a real bug fix. And discovered that the cluster I had been running for weeks had never actually worked.

The database was completely empty. No schema. No tables. Zero rows. The game had never successfully started on the Kubernetes cluster — not once, in any of the previous phases.

This post covers what I found, why it was invisible for so long, and how three separate bugs were diagnosed and resolved.


The first fix was straightforward. When a player clicks Start Game without selecting any emoji categories, the frontend sends categories: null to the backend. The backend Joi validation schema requires an array. null is not an array. The API returns a 400 Bad Request and the game shows an error notification.

The fix was one line in frontend/src/scripts/game.js:

// Before
categories: selectedCategories.length > 0 ? selectedCategories : null,
// After
categories: selectedCategories.length > 0 ? selectedCategories : [],

An empty array is valid. The backend accepts it and uses all available categories. The fix was written, a regression test was added, and the whole thing went through the pipeline.

The pipeline ran. All five jobs went green in 2 minutes 21 seconds. The new image was deployed. ArgoCD showed Synced/Healthy.

Then I opened the browser and tried to start a game.


Before the fix: ❌ Please check your input data! 🔍

After the fix: ❌ Oops! The game got confused. Try again! 🤔

Different error. That is progress — the 400 validation rejection was gone. The request was now passing validation and reaching the database layer. But something in the database layer was failing.

The backend logs told the story immediately:

ERROR: relation "games" does not exist at character 96
POST /api/game/start 500 2078.844 ms

The backend was looking for a table that did not exist.


Two diagnostic queries confirmed it:

SELECT schema_name FROM information_schema.schemata;

Result — no game schema, only public, information_schema, pg_catalog, pg_toast.

SELECT table_schema, table_name
FROM information_schema.tables
WHERE table_schema NOT IN ('information_schema', 'pg_catalog');

Result — zero rows.

The database was completely empty. Not missing a schema. Not misconfigured. Empty. combined-init.sql — the file that creates every table, every index, every trigger, and seeds the initial data — had never run on the Kubernetes cluster.

The PostgreSQL logs confirmed why:

PostgreSQL Database directory appears to contain a database; Skipping initialization

Why Four Phases of Work Did Not Catch This

Section titled “Why Four Phases of Work Did Not Catch This”

This is the part worth understanding.

Every previous phase was verified at the infrastructure layer. Pods running. Health endpoints returning 200. ArgoCD showing Synced/Healthy. The /api/health endpoint checks whether the backend can establish a connection to PostgreSQL and Redis. A successful connection does not mean the database schema exists — it means TCP connectivity works.

The game was never actually started on the Kubernetes cluster during any of Phases 3 through 6. Infrastructure verification and application verification are different things. I had the former and assumed it implied the latter. It does not.

A single POST /api/game/start at the end of Phase 3 would have revealed the empty database immediately. That test was never run.


The empty database was not caused by one thing. Four separate problems stacked on top of each other.

Problem 1 — postgres-init-configmap.yaml was empty.

The file existed in the GitOps repository. It had the right name. It was referenced in documentation. It contained nothing. The ConfigMap was never created in the cluster because there was nothing to create.

Problem 2 — The init SQL was never mounted into the container.

Even if the ConfigMap had been populated, PostgreSQL would never have seen the SQL. The 06-postgres-deployment.yaml manifest had no volumeMount for /docker-entrypoint-initdb.d/ and no volume referencing the ConfigMap. The wiring was missing entirely.

Problem 3 — The iSCSI volume was not empty.

PostgreSQL’s entrypoint script initialises a fresh database when started against an empty data directory. The Synology iSCSI LUN was not empty — it had filesystem metadata (lost+found) at its root from the ext4 format. PostgreSQL saw a non-empty directory, assumed an existing database was present, and skipped initialisation. Once it had initialised even a minimal cluster in the pgdata/ subdirectory, every subsequent restart found a valid database and continued skipping the init scripts.

Problem 4 — kustomization.yaml was incomplete.

postgres-init-configmap.yaml was not registered in kustomization.yaml. ArgoCD never knew it existed and never tried to manage it.

Each problem alone would have been caught. Together they produced a cluster that appeared completely healthy while the database had never run a single line of initialisation SQL.


In Phase 3, Docker Compose ran the same application against the same combined-init.sql and everything worked. Twenty-five automated tests passed, including full game flow from user creation through match completion.

Docker Compose uses a bind mount:

volumes:
- ./database/combined-init.sql:/docker-entrypoint-initdb.d/combined-init.sql:ro

No ConfigMap. No Kubernetes manifest. No wiring. The file is mounted directly from the host filesystem. PostgreSQL sees it on every fresh volume. The init SQL runs automatically.

When the application moved to Kubernetes, the ConfigMap approach was planned and partially set up — the file was created, the documentation described it — but the content was never added and the volume mount was never applied. The gap between plan and reality was invisible until the first real end-to-end test.


Three changes were needed.

On sre-mgmt-01 — Kubernetes manifests:

postgres-init-configmap.yaml was populated with the full SQL content. An initContainer was added to 06-postgres-deployment.yaml to fix permissions on the PGDATA subdirectory before PostgreSQL starts. The /docker-entrypoint-initdb.d volume mount was added. kustomization.yaml was updated to register the ConfigMap.

These were committed directly to the gitops branch — no pipeline run required, because this is a Kubernetes infrastructure change, not an application code change.

ArgoCD immediately flagged OutOfSync. The sync failed. The error:

resource :Namespace is not permitted in project humor-game-safe
resource networking.k8s.io:Ingress is not permitted in project humor-game-safe

The ArgoCD AppProject has a resource type whitelist. Namespace and Ingress were never on it. Adding them to kustomization.yaml caused an immediate rejection. Both were removed. The second sync succeeded.

Then the PVC had to be deleted so PostgreSQL would reinitialise against a fresh empty volume. The Synology iSCSI PVC was stuck in Terminating — the iSCSI finalizer was holding it. A force-remove with kubectl patch completed the deletion. A new PVC was provisioned immediately.

PostgreSQL started against the fresh volume. The logs showed the init SQL running:

running /docker-entrypoint-initdb.d/combined-init.sql
CREATE EXTENSION
CREATE TABLE
CREATE TABLE
CREATE TABLE
CREATE TABLE
CREATE VIEW
CREATE INDEX (x8)
CREATE FUNCTION
CREATE TRIGGER
GRANT (x3)
ALTER ROLE
INSERT 0 8
NOTICE: 🎯 HUMOR MEMORY GAME DATABASE READY!
PostgreSQL init process complete; ready for start up.

On dev-box-01 — permanent source fix:

ALTER ROLE gameuser SET search_path TO public; was added to the end of combined-init.sql. This makes the search_path explicit in the source so every future fresh deployment — Kubernetes, Docker Compose, or local developer setup — initialises with the correct role configuration rather than relying on the PostgreSQL default.

Committed, PR raised, merged to humor-memory-game/main.


With the database now working, the backend pods showed 0 restarts across the board. But the liveness probe configuration was still a time bomb.

The original values:

livenessProbe:
initialDelaySeconds: 45
timeoutSeconds: 1
failureThreshold: 3

On a Raspberry Pi under load, a PostgreSQL health check that takes 1.1 seconds counts as a timeout failure. Three consecutive failures — 105 seconds after pod start — and Kubernetes kills the pod. The restarted pod faces the same unavailable database. The cycle repeats with exponential backoff: 10s, 20s, 40s, 80s, 160s, 300s maximum. Recovery from a pod restart loop on constrained hardware takes many minutes.

The fix was straightforward — more tolerant values for ARM64 hardware:

livenessProbe:
initialDelaySeconds: 90
timeoutSeconds: 5
failureThreshold: 5

Applied via direct GitOps commit to the gitops branch. ArgoCD picked it up, rolled out the update, pods came up clean.


After all three fixes were in place, the verification was simple. Open a browser. Navigate to http://192.168.30.20:30080. Enter a username, select Easy difficulty, leave all emoji categories unchecked, click Start Game.

A 4x4 card grid appeared. Timer running. Player name displayed. 0/8 pairs.

The first confirmed end-to-end working game session on the Kubernetes cluster. After six phases of infrastructure work.


Everything up to Phase 6 demonstrates that I can build infrastructure. Phase 7 demonstrates something different — that I can validate it, find what is wrong when it does not work, and reason through problems that span multiple layers simultaneously.

The database bug required understanding PostgreSQL initialisation behaviour, Kubernetes ConfigMap wiring, iSCSI storage semantics, and ArgoCD AppProject resource whitelists — all at once. No single diagnostic tool surfaces all of that. It requires working through each layer methodically.

That is the work. Not the setup. The diagnosis.


Infrastructure health does not imply application correctness. A pod showing Running and a health endpoint returning 200 tells you the process is alive and connectivity works. It does not tell you the application can do its job. End-to-end smoke tests — actual game start requests, not just health pings — must be part of every phase verification.

Empty placeholder files in a GitOps repository are dangerous. A file with the right name, in the right location, containing nothing is indistinguishable from a correctly configured resource without reading its content. Never commit empty configuration files.

PostgreSQL init scripts only run on a completely empty data directory. Any content — including filesystem metadata from storage provisioning — prevents initialisation. For iSCSI-backed storage, the PGDATA subdirectory configuration is mandatory, and fresh volumes must be confirmed empty before first use.

Different change types require different deployment paths. Application code goes through the CI/CD pipeline. Kubernetes manifest changes go directly to the GitOps branch. Both paths are correct — but only for their intended change type. Using the wrong path for a given change either does nothing or bypasses the audit trail.


Phase 8 closes the loop — Cloudflare Tunnel makes the game publicly accessible at a real URL, turning a homelab project into something anyone can open in a browser and try for themselves.

← Phase 6 — GitOps and Automated Deployments with ArgoCD


Repository: sjchristie/humor-memory-game Phase 7 documentation: docs/phase-6-validation/