Migration from the v1beta1 GitLab resource

Status: Implemented Issue: https://gitlab.com/gitlab-org/cloud-native/gitlab-operator/-/work_items/2332 Parent: none

Goal

An administrator moves an instance that a v1beta1 GitLab manages to a GitLabCore, keeping its repositories, Secrets, and external data, and accepting a short downtime. Both reconcilers stay in the Operator. For the design, see ADR 42.

Requirements

  • kubectl bridge migrate <name> [--namespace <namespace>] migrates the GitLab of that name to a GitLabCore of the same name and namespace.
  • The command refuses, with the reason, and changes nothing when:
    • the GitLab runs a chart older than 10.5.0;
    • the GitLab is not Running with Available true, or is upgrading;
    • its effective values turn on the bundled nginx-ingress or nginx-ingress-geo, which the GitLabCore forces off;
    • its effective values request cert-manager certificates for its Ingresses (global.ingress.configureCertmanager);
    • the cluster does not serve gitlabcores.apps.gitlab.com, or no ready Operator with ENABLE_BRIDGE=true watches the namespace;
    • the Operator is rolling out, because a manager of the previous version may still apply objects;
    • the version of the plugin and the version of the Operator are both known and differ;
    • a GitLabCore of that name exists, unless a migration that resumes created it;
    • the ConfigMap of a migration records another GitLab of the same name.
  • The command warns, and continues only after confirmation, when:
    • the GitLab carries the labels or annotations of Argo CD, Flux, or Helm;
    • the plugin or the Operator version is unknown, or the administrator may not list the Operator;
    • the GitLab runs the bundled Prometheus, which a GitLabCore forces off. The one warning names the volume claims of its history, which the delete removes;
    • the delete removes other volume claims the GitLab owns, such as the Toolbox scratch volumes;
    • the draft drops the app.kubernetes.io labels the v1beta1 controller adds.
  • Every warning and difference starts with its topic, such as Monitoring:, Persistence:, Secrets:, or Labels:.
  • The draft GitLabCore pins the chart version the GitLab runs in spec.version.chartVersion, with the Static type.
  • The draft renders with the same effective values as the GitLab, except for the differences the command lists: the shared secrets provider, the Operator overrides of GitLabCore, and the dropped values of the subcharts it forces off.
  • The draft drops the app.kubernetes.io labels the v1beta1 controller adds to every object, and keeps the labels the GitLab sets itself.
  • The draft leaves the settings of the shared secrets Job to the GitLabCore, whose GitLabSecrets controller generates the Secrets, and keeps the ones the GitLab sets itself.
  • The draft keeps OpenBao and the AI Gateway off, because the v1beta1 controller never deploys them, and lists it when the GitLab turns them on.
  • The draft keeps the components and the Gateway API setup the GitLab ran on chart defaults: the container registry, the Toolbox, the Gateway API with its Envoy configuration, and the cert-manager Issuer of the Gateway.
  • A setting moves into its structured field only when the effective values stay the same. Every other setting stays in spec.chart.values. spec.networking stays unset.
  • The draft moves global.certificates.customCAs into spec.certificates.customCAs when every entry is a map of exactly one non-empty secret or configMap name and an optional list of valid keys, with no other field, and the list holds at most 64 entries. It removes the list from spec.chart.values, and the maps that leaves empty. Otherwise, or for an empty list, the whole list stays in spec.chart.values, and the command lists the reason as a difference, except for an empty list. See trusted certificate authorities.
  • The command prints the draft and the differences, and changes nothing until the administrator confirms. --dry-run stops there. --yes confirms every prompt.
  • Before it changes the GitLab, the command stores the GitLab, its UID, and the draft in a ConfigMap named <name>-v1beta1-migration, which nothing owns.
  • The command marks the GitLab with the annotation apps.gitlab.com/migrate-to: GitLabCore, and changes nothing more until the GitLab reports the condition Migrating.
  • The v1beta1 controller applies nothing for a marked GitLab, and reports Migrating with the generation it observed. Removing the annotation hands the GitLab back, and removes the condition.
  • The v1beta1 controller applies nothing for a GitLab that is being deleted.
  • A run that stops while the GitLab stays marked says so, and prints how to hand it back.
  • The command keeps the Gateways, EnvoyProxies, LoadBalancer Services, and cert-manager Issuers of the GitLab, so their addresses and certificates survive. The GitLabCore takes over those it renders.
  • The command deletes the GitLab in the foreground. It creates the GitLabCore only after the GitLab and every pod of its release are gone.
  • The Gitaly repositories, the generated Secrets, and the external PostgreSQL, Redis, and object storage are unchanged after the migration.
  • The command waits for the GitLabCore to report Available, and reports a timeout without undoing anything.
  • Run again after an interruption, the command continues from the ConfigMap and completes the migration. While the GitLab still exists, it asks for confirmation again.

Out of scope

  • Handing an instance back to v1beta1. The user documentation of the migration describes the manual way.
  • Charts older than 10.5.0, the bundled NGINX, and cert-manager certificates for Ingresses.
  • Moving the Gateway API setup into spec.networking.
  • Migration through the Bridge API or the Bridge UI.

FAQ

  • Why delete the GitLab rather than orphan its objects? A short downtime is acceptable, and every stateful object survives the delete: the Gitaly volumes come from volume claim templates, which the GitLab does not own, and the shared secrets Job creates Secrets without an owner. A fresh install by the GitLabCore leaves no fields of the v1beta1 controller behind.
  • Why keep the Gateways, EnvoyProxies, and LoadBalancer Services? Deleting them releases the cloud load balancer, and a new one usually gets a new address, which turns a short downtime into a DNS change.
  • Why does the v1beta1 controller have to stop? It applies the objects of a GitLab on every pass, with the owner reference of the GitLab. A pass during the handover would put the reference back on an object the command keeps, and garbage collection would delete it. The controller never reconciles one GitLab twice at once, so once it reports Migrating, no such pass runs.
  • Do the shared Secrets need a migration of their own? No. A GitLabCore on chart 10.5 or later declares them in a GitLabSecrets, and its controller keeps every Secret that exists under the same name and adds only missing keys. The Job and its settings have nothing left to do.
  • Why keep the cert-manager Issuers? The v1beta1 controller creates them itself, and the GitLabCore creates none. Without them, no certificate is issued or renewed.
  • Why the same name? The release name is the name of the resource. It names the Gitaly StatefulSet, and with it the volume claims the new StatefulSet binds again.
  • Why pin the version? A new GitLabCore has no deployed version, so its first pass is an install, without the ordered upgrade steps. At the version the GitLab runs, the migrations have nothing to do.
  • Why is spec.networking left unset? Its envoyGatewayController mode names the GatewayClass after the namespace and the resource, which changes the Gateway the instance runs on.
  • Why does the plugin run the migration, and not the Operator? It is a one-time step an administrator approves, with the permissions of that administrator. The translation lives in a package the Bridge API can serve later.
  • Why are HAProxy and Traefik no blockers? The v1beta1 controller never deploys them, so a GitLab that turns them on runs without them, as the GitLabCore does.
  • Why refuse cert-manager certificates for Ingresses? The chart then renders a Job that creates the Issuer with RBAC of its own, which a GitLabCore does not apply. The Gateway API, the chart default, keeps working through the Issuer the command keeps.
  • Why only warn for Argo CD and Flux? The administrator may have removed the GitLab from the repository already. The warning says that otherwise the tool recreates it and the two reconcilers compete for the instance.