Swapping WordPress for a static site with zero downtime: let the older route win
A marketing site moved from WordPress to a static export. Gateway API conflict rules let the new route sit beside the old one, taking no traffic, until one commit released the hostname.
A company marketing site ran as a WordPress install on Kubernetes, behind Gateway API and Argo CD. The developer delivered its replacement as a tarball: a static export. “Just change the image” sounded simple. Recon showed three reasons why it was not.
- The “static” export was not fully static: the lead forms posted to a small PHP script, which needed SMTP credentials nobody on the development side knew.
- A second hostname, an alias, was served by the same WordPress pod and was not in the export.
- The WordPress chart derived everything (Vault paths, the database name, the Argo CD application name) from the hostname. Changing the host or image of the existing app had a huge blast radius.
The mechanism: the older route wins
In Gateway API, when two HTTPRoutes claim the same hostname and path, the older one wins, by creationTimestamp. So a new route for the same host can be added safely: it is accepted and takes no traffic until the old one lets go.
That gave a two-commit cutover:
- The static app claims the hostname. WordPress still wins on age. I checked that by fingerprint: WordPress sends
x-powered-byandlink: </wp-json/>, the static site does not. - The WordPress element gets a new chart value,
serveHost: false: it stops claiming its main hostname and keeps only the alias. The hostname falls to the static route.
Two commits, not one, so Argo CD cannot apply them in the wrong order and leave a gap. Rollback is a git revert of the second commit: WordPress claims the host again on the next sync. The new chart value defaulted to true, and I proved that every other site rendered byte-for-byte identical.
Before the cutover: a dark run
The static image was php:apache with the export baked in and PHP denied everywhere except the form handler. I rendered the chart with a temporary hostname that had no DNS, applied it outside Argo CD and tested every path with curl --resolve against the gateway address, on both listeners. The external TLS front talks to the gateway over plain HTTP, so port 80 is a real path too.
The alias lost its styling
The alias site loaded CSS and one plugin script from the main hostname, because WordPress’ siteurl pointed there. Moving the main host to static silently stripped the alias of its styling. The fix was a narrow fallback on the static route back to WordPress, with a regex, not a prefix:
^/wp-includes/(blocks|css)/[A-Za-z0-9/._-]+\.css$
A prefix match reached PHP on WordPress: /wp-includes/blocks/index.php returned 200.
Small traps
- Double escaping. A regex written in
values.yamlas\\.cssstays a literal backslash after| quote. The route wasAcceptedand matched nothing. Read the rendered route back from the API. - Apache behind a TLS front builds
Location: http://…for directory-slash redirects.DirectorySlash Offplus a rewrite tohttps://fixed it. - SMTP envelope acceptance proves nothing on Exchange.
MAIL FROMandRCPT TOreturn 250 for any sender; Send-As is checked only afterDATA, against the headerFrom. I kept the sender WordPress had already used successfully. - The SMTP password was taken from the live WordPress plugin settings, decrypted inside the pod with the plugin’s own code and piped straight into
vault kv put … password=-. It never appeared in a terminal. The export was described as “pre-hack”, so those credentials were treated as compromised and scheduled for rotation.
Takeaways
- The Gateway API “older route wins” rule is a free blue-green switch: deploy the new route next to the old one, verify, then release the old one.
- Split a cutover into commits that are safe in any intermediate state, especially when a GitOps controller applies them.
- A “static” export is rarely fully static. Check forms, aliases and cross-host assets before you plan.
- Use regex, not prefix, for fallbacks into a PHP application, and verify by reading the rendered object back.