Migrate an Existing Instance from Ingress to Gateway API
This article describes how to switch the web entry of an existing GitLab instance from Ingress to Gateway API (HTTPRoute), for example before the Ingress controller of the cluster is removed.
Applicable scenarios:
- The cluster is moving to Gateway API and the Ingress controller will be removed.
- A new cluster only provides Gateway API, and an instance restored or migrated into it still uses the Ingress configuration.
New instances can choose Gateway API directly. See Gateway API Access.
TOC
What ChangesPrerequisitesStepsPhase 1: Add the HTTPRoute Next to the IngressPhase 2: Switch DNS and Remove the IngressRollbackTroubleshootingWhat Changes
Repositories, users and other data are not affected. Only the routing objects change. The NGINX timeout and body size annotations of the Ingress no longer apply; see the notes in Gateway API Access for the Gateway equivalents.
Prerequisites
-
The cluster has the Gateway API CRDs and a Gateway controller installed, and a
GatewayClassis available: -
A
Gatewayexists in the namespace of the instance, with anHTTPlistener that accepts the instance domain name. A minimal example:If the instance is served over HTTPS (
global.hosts.gitlab.https: true), theGatewayalso needs anHTTPSlistener with the certificate, andsectionNamebelow must name that listener. See Configure HTTPS.Wait until the
Gatewayis programmed and has an address: -
Back up the current instance definition so that it can be restored:
Steps
The migration is done in two phases so that the instance stays reachable while DNS is switched.
Phase 1: Add the HTTPRoute Next to the Ingress
Edit the instance and add gatewayRoute under gitlab.webservice, keeping Ingress enabled:
After the instance is reconciled, check that the HTTPRoute is accepted:
Accepted=True and ResolvedRefs=True are expected. Then test the new entry without changing DNS, using the address of the Gateway:
Phase 2: Switch DNS and Remove the Ingress
-
Point the instance domain name to the address of the
Gatewayand wait for the old DNS records to expire. -
Disable Ingress in the instance:
-
Check that the Ingress has been removed and the instance is still reachable:
Also verify git clone / git push over HTTP and logging in to the web UI.
Rollback
Restore the backed-up definition. Remove server-side fields such as metadata.resourceVersion, metadata.uid and status from gitlab-before-gateway.yaml first, then replace the instance with it:
Use kubectl replace rather than kubectl apply. When the instance was changed with kubectl edit or kubectl patch, kubectl apply does not remove fields that are missing from the backup, so gatewayRoute would stay enabled and the HTTPRoute would not be removed.
The Ingress is created again and the HTTPRoute is removed. Point DNS back to the Ingress controller address if it was changed.