GitLab is a complete software forge in one package: Git repositories, merge requests, issues, CI/CD pipelines, a container registry and a wiki. The Community Edition (CE) is open source and free, and for a team that wants its code and pipelines on its own hardware it’s hard to beat.
This guide builds GitLab CE on one Debian 13 VM with the official Linux package, plus a separate runner VM for CI jobs. It’s not a high-availability setup. It’s a single instance done properly: people log in through authentik, secrets come from OpenBao, pipelines build images without privileged containers and fetch their secrets from OpenBao without stored credentials, and your existing Prometheus watches all of it.
What you’ll end up with:
- GitLab CE 19.6 from GitLab’s apt repository, as a deb822 source with its own keyring, held at a tested version
- TLS from your internal CA for GitLab and a container registry on its own host name
- authentik OIDC as the only way in through the web, with authentik deciding who may use GitLab at all, and an offboarding sync that blocks GitLab accounts when authentik deactivates a user
- Instance settings as code: no sign-ups, no public projects, no webhooks into your own network, admin mode, dormant users deactivated
- Git over SSH with fast key lookup instead of a giant
authorized_keysfile - A runner VM with the Docker executor, unprivileged jobs, image builds with rootless BuildKit and a Trivy scan
- CI jobs that log in to OpenBao with their own ID token, scoped to one project and protected branch
- SSH-signed commits shown as Verified
- Prometheus scraping GitLab’s exporters, with alert rules, and a backup-age metric
- Nightly backups with
gitlab-secrets.jsonkept in OpenBao, a restore test, upgrades along the upgrade path, troubleshooting and a checklist
Written against: GitLab CE 19.6.2 (released 25 November 2026) and GitLab Runner 19.6 on Debian 13 “trixie”, authentik 2026.8 and OpenBao. All commands run as root unless noted.
Table of contents
- Architecture
- Placeholders and sizing
- Prerequisites
- Secrets in OpenBao
- gitlab.rb before the install
- Install GitLab
- authentik SSO
- Instance settings as code
- Offboarding: authentik deactivates, GitLab blocks
- Git over SSH with fast key lookup
- Container registry
- The runner VM
- A pipeline: rootless build, scan, push
- Pipeline secrets from OpenBao with ID tokens
- Signed commits and protected branches
- Monitoring with your Prometheus
- Firewall
- Backups and a restore test
- Upgrades
- Troubleshooting
- Checklist
1. Architecture

The Linux package (still often called Omnibus) ships everything GitLab needs and manages it with gitlab-ctl:
| Service | Does |
|---|---|
| nginx | TLS for gitlab.mydomain.local and registry.mydomain.local |
| gitlab-workhorse | Smart reverse proxy: Git over HTTPS, uploads, artifacts, long requests |
| puma | The Rails application: web UI and API |
| sidekiq | Background jobs: mails, pipelines, webhooks, housekeeping |
| gitaly | All Git repository access |
| postgresql, redis | Database, cache and job queues, local to the VM |
| registry | The container registry |
| gitlab-shell | Git over SSH, called by the system sshd |
| exporters | gitlab-exporter, postgres, redis, Gitaly, Workhorse and Sidekiq metrics for your Prometheus |
CI jobs never run on the GitLab VM. They run on a separate runner VM, so a hostile or broken job can’t touch the repositories or the database.
Availability: one VM. vSphere HA restarts it if its host dies, and section 18 rebuilds it from the nightly backup. While GitLab is down, nobody can push or run pipelines, but nothing already deployed stops working.
2. Placeholders and sizing
| Placeholder | Meaning |
|---|---|
gitlab.mydomain.local / 10.20.0.100 / 2001:db8:20::100 | The GitLab VM |
registry.mydomain.local | Container registry, same VM and IP |
runner-01.mydomain.local / 10.20.0.101 / 2001:db8:20::101 | The runner VM |
auth.mydomain.com | authentik |
bao.mydomain.local | OpenBao, KV v2 at kv/ |
mail.mydomain.local:587 | SMTP relay with STARTTLS |
10.20.0.90 / 2001:db8:20::90 | Prometheus |
10.10.0.0/16, 2001:db8:10::/48 | Staff networks |
/etc/ssl/mydomain-ca.crt | Your internal CA certificate |
| VM | Size | Disks |
|---|---|---|
gitlab | 8 vCPU, 16 GB | 40 GB system, 200 GB at /var/opt/gitlab, 200 GB at /var/opt/gitlab/backups |
runner-01 | 4 vCPU, 8 GB | 40 GB system, 100 GB at /var/lib/docker |
GitLab runs on 4 vCPU and 8 GB for a small team, but it uses every bit of it, and the first big pipeline or import makes it slow. Put the repositories and the backups on separate disks, so a full backup disk can’t stop pushes, and size the data disk for repositories, registry images and CI artifacts together.
3. Prerequisites
On both VMs:
apt update
apt install -y curl ca-certificates gnupg jq openssh-server
cp mydomain-ca.crt /usr/local/share/ca-certificates/mydomain-ca.crt
update-ca-certificates
ln -sf /usr/local/share/ca-certificates/mydomain-ca.crt /etc/ssl/mydomain-ca.crt
DNS:
gitlab.mydomain.localandregistry.mydomain.local: A10.20.0.100, AAAA2001:db8:20::100runner-01.mydomain.local: A10.20.0.101, AAAA2001:db8:20::101
Certificates from your CA:
- one for
gitlab.mydomain.local - one for
registry.mydomain.local
On the GitLab VM:
install -d -m 0755 /etc/gitlab /etc/gitlab/trusted-certs
install -d -m 0700 /etc/gitlab/ssl
install -m 0644 gitlab.mydomain.local.crt /etc/gitlab/ssl/
install -m 0600 gitlab.mydomain.local.key /etc/gitlab/ssl/
install -m 0644 registry.mydomain.local.crt /etc/gitlab/ssl/
install -m 0600 registry.mydomain.local.key /etc/gitlab/ssl/
cp /etc/ssl/mydomain-ca.crt /etc/gitlab/trusted-certs/mydomain-ca.crt
GitLab doesn’t use the system CA store. It ships its own OpenSSL with its own bundle. Every CA that GitLab must trust (for authentik, OpenBao, the mail relay or webhooks) goes into
/etc/gitlab/trusted-certs/, andgitlab-ctl reconfigureadds it. Forgetting this is the classic cause ofSSL_connect ... certificate verify failedat the first SSO login.
4. Secrets in OpenBao
export BAO_ADDR=https://bao.mydomain.local:8200
bao login -method=oidc
bao kv put kv/gitlab/app \
root_password="$(openssl rand -base64 33 | tr -d '/+=')" \
smtp_password="<from the mail relay>" \
oidc_client_id="<from authentik, section 7>" \
oidc_client_secret="<from authentik, section 7>" \
authentik_api_token="<from authentik, section 9>"Code language: JavaScript (javascript)
Write them to root-only files on the GitLab VM:
install -d -m 0700 /etc/gitlab/secrets
cd /etc/gitlab/secrets
umask 077
for k in root_password smtp_password oidc_client_id oidc_client_secret authentik_api_token; do
bao kv get -field="$k" kv/gitlab/app | tr -d '\n' > "$k"
done
ls -l /etc/gitlab/secretsCode language: PHP (php)
gitlab.rb reads these files at every reconfigure, so gitlab.rb itself contains no secrets and can live in Git. The values still end up in the configuration files GitLab generates under /var/opt/gitlab, readable by its own service users. That’s unavoidable and fine.
| Secret | Why it matters |
|---|---|
root_password | The break-glass root account. Used once, at the first start |
smtp_password | Mail relay login |
oidc_client_* | authentik client, filled in during section 7 |
authentik_api_token | Read-only token for the offboarding sync (section 9) |
gitlab-secrets.json | Created by GitLab at install. Encrypts CI variables, 2FA secrets and tokens in the database. Goes into OpenBao in section 6, because a database backup without it is half useless |
5. gitlab.rb before the install
The package runs gitlab-ctl reconfigure right after installing. If /etc/gitlab/gitlab.rb already exists, it uses that file, so the very first start already has TLS, SSO and the final settings.
/etc/gitlab/gitlab.rb:
external_url 'https://gitlab.mydomain.local'
registry_external_url 'https://registry.mydomain.local'
gitlab_rails['time_zone'] = 'UTC'
gitlab_rails['initial_root_password'] = File.read('/etc/gitlab/secrets/root_password').strip
gitlab_rails['store_initial_root_password'] = false
## TLS from the internal CA
letsencrypt['enable'] = false
nginx['ssl_certificate'] = '/etc/gitlab/ssl/gitlab.mydomain.local.crt'
nginx['ssl_certificate_key'] = '/etc/gitlab/ssl/gitlab.mydomain.local.key'
nginx['ssl_protocols'] = 'TLSv1.2 TLSv1.3'
nginx['redirect_http_to_https'] = true
nginx['hsts_max_age'] = 31536000
registry_nginx['ssl_certificate'] = '/etc/gitlab/ssl/registry.mydomain.local.crt'
registry_nginx['ssl_certificate_key'] = '/etc/gitlab/ssl/registry.mydomain.local.key'
registry_nginx['ssl_protocols'] = 'TLSv1.2 TLSv1.3'
registry['storage_delete_enabled'] = true
## Mail
gitlab_rails['gitlab_email_from'] = 'gitlab@mydomain.com'
gitlab_rails['gitlab_email_reply_to'] = 'noreply@mydomain.com'
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = 'mail.mydomain.local'
gitlab_rails['smtp_port'] = 587
gitlab_rails['smtp_user_name'] = 'gitlab@mydomain.com'
gitlab_rails['smtp_password'] = File.read('/etc/gitlab/secrets/smtp_password').strip
gitlab_rails['smtp_domain'] = 'mydomain.com'
gitlab_rails['smtp_authentication'] = 'login'
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = false
gitlab_rails['smtp_openssl_verify_mode'] = 'peer'
## authentik (section 7)
gitlab_rails['omniauth_enabled'] = true
gitlab_rails['omniauth_allow_single_sign_on'] = ['openid_connect']
gitlab_rails['omniauth_block_auto_created_users'] = false
gitlab_rails['omniauth_auto_sign_in_with_provider'] = 'openid_connect'
gitlab_rails['omniauth_sync_profile_from_provider'] = ['openid_connect']
gitlab_rails['omniauth_sync_profile_attributes'] = ['name', 'email']
gitlab_rails['omniauth_sync_email_from_provider'] = 'openid_connect'
gitlab_rails['omniauth_providers'] = [
{
name: 'openid_connect',
label: 'authentik',
args: {
name: 'openid_connect',
scope: ['openid', 'profile', 'email'],
response_type: 'code',
issuer: 'https://auth.mydomain.com/application/o/gitlab/',
discovery: true,
client_auth_method: 'basic',
uid_field: 'sub',
send_scope_to_token_endpoint: false,
pkce: true,
client_options: {
identifier: File.read('/etc/gitlab/secrets/oidc_client_id').strip,
secret: File.read('/etc/gitlab/secrets/oidc_client_secret').strip,
redirect_uri: 'https://gitlab.mydomain.local/users/auth/openid_connect/callback'
}
}
}
]
## SSH (section 10)
gitlab_rails['gitlab_shell_ssh_port'] = 22
## Monitoring with your own Prometheus (section 16)
prometheus['enable'] = false
alertmanager['enable'] = false
node_exporter['enable'] = false
gitlab_rails['monitoring_whitelist'] = ['127.0.0.0/8', '::1/128', '10.20.0.90/32', '2001:db8:20::90/128']
gitlab_exporter['listen_address'] = '10.20.0.100'
gitlab_exporter['listen_port'] = '9168'
gitlab_workhorse['prometheus_listen_addr'] = '10.20.0.100:9229'
sidekiq['listen_address'] = '10.20.0.100'
redis_exporter['listen_address'] = '10.20.0.100:9121'
postgres_exporter['listen_address'] = '10.20.0.100:9187'
gitaly['configuration'] = { prometheus_listen_addr: '10.20.0.100:9236' }
registry['debug_addr'] = '10.20.0.100:5001'
## Backups (section 18)
gitlab_rails['backup_path'] = '/var/opt/gitlab/backups'
gitlab_rails['backup_keep_time'] = 604800
gitlab_rails['backup_archive_permissions'] = 0640Code language: PHP (php)
chmod 600 /etc/gitlab/gitlab.rb
Notes:
uid_field: 'sub'links each GitLab account to authentik’s stable subject, not to the username. A renamed user in authentik stays the same GitLab user.omniauth_block_auto_created_users = false: new SSO users are active immediately. That’s safe here because authentik only lets members of one group through (section 7).omniauth_auto_sign_in_with_providersends the login page straight to authentik. Nobody sees a password form.- There’s no
omniauth_auto_link_user. Auto-linking matches SSO logins to existing local accounts by e-mail address, so it’s only as safe as the IdP’s e-mail verification. Link the few existing accounts by hand instead (section 7.3). - Bundled Prometheus, Alertmanager and node_exporter are off. Your own Prometheus and node_exporter already run. The other exporters listen on the VM’s address, and the firewall lets only Prometheus reach them.
- Small VM? Add
puma['worker_processes'] = 2andsidekiq['concurrency'] = 10, and expect it to feel slower under load.
6. Install GitLab
Add the repository as a deb822 source with its own keyring:
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey -o /etc/apt/keyrings/gitlab-ce.asc
gpg --show-keys /etc/apt/keyrings/gitlab-ce.asc
cat > /etc/apt/sources.list.d/gitlab-ce.sources <<'EOF'
Types: deb
URIs: https://packages.gitlab.com/gitlab/gitlab-ce/debian/
Suites: trixie
Components: main
Signed-By: /etc/apt/keyrings/gitlab-ce.asc
EOF
apt update
apt-cache madison gitlab-ce | head -n 5Code language: JavaScript (javascript)
GitLab’s own instructions pipe
script.deb.shintobash. Read that script once instead: it shows the current key URL and repository line. If they differ from the ones above, use the script’s.
Install a specific version and hold it:
apt install gitlab-ce=19.6.2-ce.0
apt-mark hold gitlab-ce
The install takes a few minutes and ends with gitlab Reconfigured!. Check it:
gitlab-ctl status
gitlab-rake gitlab:check SANITIZE=true
curl -sS https://gitlab.mydomain.local/-/readiness | jq # all "ok"Code language: JavaScript (javascript)
Save gitlab-secrets.json to OpenBao now, before anything else is stored in the database:
bao kv put kv/gitlab/secrets-json json=@/etc/gitlab/gitlab-secrets.json
sha256sum /etc/gitlab/gitlab-secrets.json
Repeat that after every upgrade (section 19), because new versions sometimes add keys to the file.
7. authentik SSO

7.1 Who decides what
On GitLab CE, the OIDC group features (required_groups, admin_groups, external_groups) aren’t available. They need Premium. So the job is split:
| Question | Answered by |
|---|---|
| May this person use GitLab at all? | authentik: a policy binding on the application, group gitlab-users |
| MFA, password policy, session length | authentik flows |
| Which groups and projects, with which role? | GitLab groups and their members |
| Who is an administrator? | GitLab, set by hand, with admin mode on (section 8) |
| What happens when someone leaves? | authentik deactivates, the sync in section 9 blocks them in GitLab |
7.2 authentik
- Applications → Providers → Create → OAuth2/OpenID Provider, with the settings in the table below.
- Applications → Applications → Create: name
GitLab, sluggitlab(it’s part of the issuer URL), providergitlab, launch URLhttps://gitlab.mydomain.local. - Directory → Groups: create
gitlab-usersand add the people who should have access. - On the application, Policy / Group / User Bindings → Bind existing group:
gitlab-users. With a binding in place, everyone else gets “Permission denied” from authentik and never reaches GitLab.
| Provider setting | Value |
|---|---|
| Name | gitlab |
| Authorization flow | default-provider-authorization-implicit-consent |
| Client type | Confidential |
| Redirect URI (strict) | https://gitlab.mydomain.local/users/auth/openid_connect/callback |
| Signing key | Your authentik certificate (RS256) |
| Scopes | openid, email, profile |
| Subject mode | Based on the User’s hashed ID |
Copy the client ID and secret into OpenBao and onto the VM:
bao kv patch kv/gitlab/app oidc_client_id='...' oidc_client_secret='...'
cd /etc/gitlab/secrets && umask 077
bao kv get -field=oidc_client_id kv/gitlab/app | tr -d '\n' > oidc_client_id
bao kv get -field=oidc_client_secret kv/gitlab/app | tr -d '\n' > oidc_client_secret
gitlab-ctl reconfigureCode language: JavaScript (javascript)
Check discovery from the GitLab VM, with GitLab’s own OpenSSL bundle:
/opt/gitlab/embedded/bin/curl -sS https://auth.mydomain.com/application/o/gitlab/.well-known/openid-configuration | jq .issuerCode language: JavaScript (javascript)
7.3 First logins
Open https://gitlab.mydomain.local. You land on authentik, log in, and come back as a new GitLab user.
Make yourself an admin with the break-glass root account. Automatic sign-in skips the password form, so use the bypass URL:
https://gitlab.mydomain.local/users/sign_in?auto_sign_in=falseCode language: JavaScript (javascript)
Log in as root with the password from OpenBao, then go to Admin → Users → (you) → Edit → Access level: Administrator.
Existing local accounts (from an older installation) link themselves: the user signs in with their password once, then User settings → Account → Service sign-in → Connect for authentik.
7.4 Break-glass
Section 8 switches password login off for the web interface, root included. If authentik is down and you need in:
gitlab-rails runner 'ApplicationSetting.current.update!(password_authentication_enabled_for_web: true)'Code language: JavaScript (javascript)
Log in as root through ?auto_sign_in=false, fix things, and run the same command with false afterwards. It’s deliberately a shell action on the server: it leaves a trace, and nobody can use it from the internet.
8. Instance settings as code
Admin settings live in the database. Clicking through Admin → Settings works, but nobody remembers later what was changed and why. Put them in a file and apply them with gitlab-rails runner. An unknown setting name makes it fail loudly, which is what you want.
/etc/gitlab/instance-settings.rb:
private_level = Gitlab::VisibilityLevel::PRIVATE
public_level = Gitlab::VisibilityLevel::PUBLIC
ApplicationSetting.current.update!(
# Access: authentik only, no sign-ups, no passwords
signup_enabled: false,
password_authentication_enabled_for_web: false,
password_authentication_enabled_for_git: false,
admin_mode: true,
# Nothing public, private by default
restricted_visibility_levels: [public_level],
default_project_visibility: private_level,
default_group_visibility: private_level,
default_snippet_visibility: private_level,
# Webhooks and integrations may not call into your own network
allow_local_requests_from_web_hooks_and_services: false,
allow_local_requests_from_system_hooks: false,
# Housekeeping
deactivate_dormant_users: true,
deactivate_dormant_users_period: 90,
default_branch_name: 'main',
max_artifacts_size: 200,
# No calls home
gravatar_enabled: false,
usage_ping_enabled: false
)
puts 'instance settings applied'Code language: PHP (php)
gitlab-rails runner /etc/gitlab/instance-settings.rb
Why these:
password_authentication_enabled_for_git: false: Git over HTTPS takes a personal access token or a deploy token, never an account password. SSH keys are the everyday way.admin_mode: administrators work as normal users until they explicitly enter admin mode, and entering it re-authenticates them through authentik. A stolen admin session cookie alone isn’t enough.restricted_visibility_levels: nobody can make a project or group public, not even by accident.- Local requests off: a webhook pointing at
https://bao.mydomain.localorhttp://10.20.0.1is refused. That closes the classic server-side request forgery route through webhooks. If a webhook legitimately targets an internal system (a chat server, say), add just that host under Admin → Settings → Network → Outbound requests → Local IP addresses and domain names that hooks and integrations can access. - Dormant users: accounts without activity for 90 days are deactivated, which frees nothing in CE but removes forgotten access.
Keep instance-settings.rb in Git with gitlab.rb, and run it again after every change.
9. Offboarding: authentik deactivates, GitLab blocks
Here is the gap every SSO setup has: when someone leaves and you deactivate them in authentik, they can’t log in to the web interface anymore. But their SSH keys and personal access tokens still work, because Git over SSH and the API never ask authentik. A blocked GitLab user loses all of that at once.
The sync runs every 15 minutes, asks authentik for deactivated users, and blocks the matching GitLab accounts.
In authentik:
- Directory → Users → Create service account:
svc-gitlab-sync. - Directory → Roles: a role
gitlab-syncwith only the permission Can view User, assigned to a group that contains the service account. - Directory → Tokens and App passwords → Create: an API token for
svc-gitlab-sync, with an expiry. Store it in OpenBao asauthentik_api_tokenand in/etc/gitlab/secrets/authentik_api_token(section 4).
/usr/local/lib/gitlab-offboard.rb:
uids = File.readlines(ARGV.fetch(0), chomp: true).reject(&:empty?)
Identity.where(provider: 'openid_connect', extern_uid: uids).find_each do |identity|
user = identity.user
next if user.nil? || user.blocked?
if user.block
puts "blocked #{user.username}"
else
warn "could not block #{user.username}"
end
endCode language: PHP (php)
/usr/local/sbin/gitlab-offboard:
#!/bin/bash
set -euo pipefail
TOKEN=$(cat /etc/gitlab/secrets/authentik_api_token)
OUT=$(mktemp)
trap 'rm -f "$OUT"' EXIT
page=1
while :; do
r=$(/opt/gitlab/embedded/bin/curl -fsS -H "Authorization: Bearer $TOKEN" \
"https://auth.mydomain.com/api/v3/core/users/?is_active=false&page_size=100&page=$page")
jq -r '.results[].uid' <<<"$r" >> "$OUT"
page=$(jq -r '.pagination.next' <<<"$r")
[ "$page" = 0 ] && break
done
gitlab-rails runner /usr/local/lib/gitlab-offboard.rb "$OUT"Code language: PHP (php)
The authentik uid field is the same hashed ID that authentik sends as sub, which GitLab stored as the identity’s extern_uid at the first login. That’s why uid_field: 'sub' and the subject mode in section 7 matter.
/etc/systemd/system/gitlab-offboard.service and .timer:
[Unit]
Description=Block GitLab users that are deactivated in authentik
After=gitlab-runsvdir.service
[Service]
Type=oneshot
ExecStart=/usr/local/sbin/gitlab-offboardCode language: JavaScript (javascript)
[Unit]
Description=Run gitlab-offboard every 15 minutes
[Timer]
OnBootSec=10min
OnUnitActiveSec=15min
[Install]
WantedBy=timers.target
chmod 750 /usr/local/sbin/gitlab-offboard
systemctl daemon-reload
systemctl enable --now gitlab-offboard.timer
systemctl start gitlab-offboard.service && journalctl -u gitlab-offboard -n 20
Test it with a test user: log in once through authentik, add an SSH key, deactivate the user in authentik, wait for the timer, and check that ssh -T git@gitlab.mydomain.local with that key now fails. Reactivating in authentik doesn’t unblock: an admin does that deliberately under Admin → Users.
10. Git over SSH with fast key lookup
By default GitLab writes every user’s SSH key into ~git/.ssh/authorized_keys, and sshd reads that file from top to bottom at every connection. With a few thousand keys it gets slow, and the file can drift out of sync. With fast lookup, sshd asks GitLab for the one key it needs.
/etc/ssh/sshd_config.d/50-gitlab.conf:
Match User git
PasswordAuthentication no
KbdInteractiveAuthentication no
AuthorizedKeysCommand /opt/gitlab/embedded/service/gitlab-shell/bin/gitlab-shell-authorized-keys-check git %u %k
AuthorizedKeysCommandUser git
Match all
sshd -t && systemctl reload ssh
Test with a user’s key before switching the file off:
ssh -T git@gitlab.mydomain.local # Welcome to GitLab, @jdoe!Code language: CSS (css)
Then stop GitLab from writing authorized_keys, and empty it:
gitlab-rails runner 'ApplicationSetting.current.update!(authorized_keys_enabled: false)'
: > /var/opt/gitlab/.ssh/authorized_keys
ssh -T git@gitlab.mydomain.local # still works: fast lookup answeredCode language: PHP (php)
Add authorized_keys_enabled: false to instance-settings.rb too.
Host keys: Debian generated ed25519, ECDSA and RSA host keys at install. Users see their fingerprints under Help → Instance configuration, so they can check the first connection instead of typing yes blindly. If you restore to a new VM, restore the old host keys too (section 18), or every developer gets a host key warning.
11. Container registry
Every project gets its own image path: registry.mydomain.local/<group>/<project>. CI jobs log in with a job token automatically. People log in with a personal access token that has the read_registry or write_registry scope.
docker login registry.mydomain.local # username + personal access tokenCode language: CSS (css)
Cleanup policies keep it from growing forever. Per project, under Settings → Packages and registries → Cleanup policies:
- Run weekly
- Keep the 10 most recent tags per image
- Keep tags matching
v.+andmain - Remove tags older than 30 days
The policy only removes tags. The layers stay on disk until garbage collection, which needs the registry stopped or read-only. Run it monthly at night:
/etc/systemd/system/gitlab-registry-gc.service:
[Unit]
Description=GitLab container registry garbage collection
[Service]
Type=oneshot
ExecStart=/opt/gitlab/bin/gitlab-ctl registry-garbage-collect -mCode language: JavaScript (javascript)
/etc/systemd/system/gitlab-registry-gc.timer:
[Unit]
Description=Monthly registry garbage collection
[Timer]
OnCalendar=Sun *-*-01..07 03:30
Persistent=true
[Install]
WantedBy=timers.targetCode language: JavaScript (javascript)
systemctl daemon-reload && systemctl enable --now gitlab-registry-gc.timerCode language: CSS (css)
-m also removes untagged manifests. The registry is down for the few minutes this takes, so pick a time without pipelines.
12. The runner VM
12.1 Docker and the runner
apt install -y docker.io
cat > /etc/docker/daemon.json <<'EOF'
{
"log-driver": "local",
"log-opts": { "max-size": "20m", "max-file": "3" },
"live-restore": true
}
EOF
systemctl restart docker
curl -fsSL https://packages.gitlab.com/runner/gitlab-runner/gpgkey -o /etc/apt/keyrings/gitlab-runner.asc
cat > /etc/apt/sources.list.d/gitlab-runner.sources <<'EOF'
Types: deb
URIs: https://packages.gitlab.com/runner/gitlab-runner/debian/
Suites: trixie
Components: main
Signed-By: /etc/apt/keyrings/gitlab-runner.asc
EOF
apt update
apt-cache madison gitlab-runner | head -n 3
apt install gitlab-runner gitlab-runner-helper-images # the 19.6 version shown above
apt-mark hold gitlab-runner gitlab-runner-helper-imagesCode language: PHP (php)
Keep the runner on the same major and minor version as GitLab.
12.2 Register it
In GitLab: Admin → CI/CD → Runners → New instance runner:
- tags
docker,linux - Run untagged jobs on
- description
runner-01
GitLab shows a runner authentication token starting with glrt-. That token is the runner’s identity from then on. (The old registration tokens are deprecated and scheduled for removal in GitLab 20.)
install -d -m 0700 /etc/gitlab-runner/certs
cp /etc/ssl/mydomain-ca.crt /etc/gitlab-runner/certs/mydomain-ca.crt
read -rs RUNNER_TOKEN
gitlab-runner register --non-interactive \
--url https://gitlab.mydomain.local \
--token "$RUNNER_TOKEN" \
--tls-ca-file /etc/gitlab-runner/certs/mydomain-ca.crt \
--executor docker \
--docker-image debian:trixie-slim \
--description runner-01
unset RUNNER_TOKENCode language: PHP (php)
12.3 config.toml
Adjust /etc/gitlab-runner/config.toml to this:
concurrent = 4
check_interval = 3
shutdown_timeout = 0
[[runners]]
name = "runner-01"
url = "https://gitlab.mydomain.local"
token = "glrt-..."
tls-ca-file = "/etc/gitlab-runner/certs/mydomain-ca.crt"
executor = "docker"
[runners.docker]
image = "debian:trixie-slim"
privileged = false
cap_drop = ["NET_RAW"]
memory = "4g"
cpus = "2"
volumes = ["/cache"]
pull_policy = ["if-not-present"]
allowed_pull_policies = ["always", "if-not-present"]Code language: JavaScript (javascript)
chmod 600 /etc/gitlab-runner/config.toml
systemctl restart gitlab-runner
gitlab-runner verify
privileged = falseis the most important line in this file. A privileged job container is root on the runner VM, and from there on every other job’s secrets. Docker-in-Docker needs privileged mode, so this guide builds images with rootless BuildKit instead (section 13).- Never mount
/var/run/docker.sockinto jobs, for the same reason. memoryandcpuskeep one runaway test from starving the other three jobs.tls-ca-filemakes the runner trust GitLab, and jobs get the same CA as the file variableCI_SERVER_TLS_CA_FILE.
12.4 Clean up images
Job images and build caches pile up. A weekly prune:
/etc/systemd/system/docker-prune.service:
[Unit]
Description=Remove unused Docker images and volumes older than a week
[Service]
Type=oneshot
ExecStart=/usr/bin/docker system prune --all --force --filter until=168h
ExecStart=/usr/bin/docker volume prune --forceCode language: JavaScript (javascript)
/etc/systemd/system/docker-prune.timer:
[Unit]
Description=Weekly Docker prune
[Timer]
OnCalendar=Sun 04:00
Persistent=true
[Install]
WantedBy=timers.targetCode language: JavaScript (javascript)
systemctl daemon-reload && systemctl enable --now docker-prune.timerCode language: CSS (css)
13. A pipeline: rootless build, scan, push

.gitlab-ci.yml for a project with a Dockerfile:
stages: [build, scan, deploy]
variables:
IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
build:
stage: build
image:
name: moby/buildkit:rootless
entrypoint: [""]
variables:
BUILDKITD_FLAGS: --oci-worker-no-process-sandbox
before_script:
- mkdir -p ~/.docker ~/.config/buildkit
- AUTH=$(printf '%s:%s' "$CI_REGISTRY_USER" "$CI_REGISTRY_PASSWORD" | base64 | tr -d '\n')
- printf '{"auths":{"%s":{"auth":"%s"}}}' "$CI_REGISTRY" "$AUTH" > ~/.docker/config.json
- printf '[registry."%s"]\n ca = ["%s"]\n' "$CI_REGISTRY" "$CI_SERVER_TLS_CA_FILE" > ~/.config/buildkit/buildkitd.toml
script:
- buildctl-daemonless.sh build
--frontend dockerfile.v0
--local context=.
--local dockerfile=.
--output type=image,name=$IMAGE,push=true
scan:
stage: scan
image:
name: aquasec/trivy:latest
entrypoint: [""]
variables:
TRIVY_USERNAME: $CI_REGISTRY_USER
TRIVY_PASSWORD: $CI_REGISTRY_PASSWORD
SSL_CERT_FILE: $CI_SERVER_TLS_CA_FILE
script:
- trivy image --exit-code 1 --severity CRITICAL --ignore-unfixed --no-progress "$IMAGE"Code language: PHP (php)
How it works:
- BuildKit rootless runs as an ordinary user in an ordinary, unprivileged container.
--oci-worker-no-process-sandboxtells it not to create its own namespaces forRUNsteps, which is what would otherwise need extra privileges. TheRUNsteps then share the build container’s process namespace, which is fine for a container that exists only for this one build. - The registry login uses the job’s own
CI_REGISTRY_USERandCI_REGISTRY_PASSWORD. They’re valid only while the job runs, and only for this project’s images. - The CA reaches BuildKit through
buildkitd.tomland Trivy throughSSL_CERT_FILE, both fromCI_SERVER_TLS_CA_FILE. - Trivy fails the pipeline on a critical vulnerability that has a fix. Without
--ignore-unfixedyou’d block on problems nobody can fix yet. Trivy downloads its vulnerability database fromghcr.ioat each run, so the runner needs outbound HTTPS. - Pin the images (
moby/buildkit:v0.x.y-rootless,aquasec/trivy:0.x.y) once it works, and let Renovate or a monthly review move them forward.latestis only here to keep the example short.
Images are tagged with the commit SHA, so every image can be traced back to the exact commit that built it. Tag releases with v1.2.3 in a separate job on Git tags.
14. Pipeline secrets from OpenBao with ID tokens
The usual way to give a deploy job a password is a masked CI/CD variable: a long-lived secret stored in GitLab, readable by every maintainer of the project. Better: the job proves who it is to OpenBao, and OpenBao hands it a secret for a few minutes.
GitLab can give every job a signed ID token (a JWT). It says which project, branch and pipeline the job belongs to, and whether the branch is protected. OpenBao checks the signature against GitLab’s public keys and the claims against a role. (GitLab’s built-in secrets:vault keyword needs Premium. The ID token itself is in CE, and the login below is three lines of shell.)
14.1 OpenBao
export BAO_ADDR=https://bao.mydomain.local:8200
bao auth enable -path=gitlab jwt
bao write auth/gitlab/config \
oidc_discovery_url="https://gitlab.mydomain.local" \
bound_issuer="https://gitlab.mydomain.local" \
oidc_discovery_ca_pem=@/etc/ssl/mydomain-ca.crt
bao policy write ci-myapp-deploy - <<'EOF'
path "kv/data/ci/myapp/*" { capabilities = ["read"] }
EOF
bao write auth/gitlab/role/myapp-deploy - <<'EOF'
{
"role_type": "jwt",
"policies": ["ci-myapp-deploy"],
"token_explicit_max_ttl": 300,
"user_claim": "user_email",
"bound_audiences": ["https://bao.mydomain.local"],
"bound_claims": {
"project_path": "infra/myapp",
"ref": "main",
"ref_type": "branch",
"ref_protected": "true"
}
}
EOF
bao kv put kv/ci/myapp/db password="$(openssl rand -base64 33 | tr -d '/+=')"Code language: JavaScript (javascript)
The role only matches jobs from infra/myapp, on the protected main branch. A job on a feature branch, or from a fork, or from another project, gets “claim mismatch”. The token lives five minutes and can only read kv/ci/myapp/*.
14.2 The job
deploy:
stage: deploy
image: debian:trixie-slim
id_tokens:
BAO_ID_TOKEN:
aud: https://bao.mydomain.local
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
before_script:
- apt-get update -qq && apt-get install -y -qq curl jq >/dev/null
script:
- BAO=https://bao.mydomain.local:8200
- BAO_TOKEN=$(curl -fsS --cacert "$CI_SERVER_TLS_CA_FILE"
--data "{\"role\":\"myapp-deploy\",\"jwt\":\"$BAO_ID_TOKEN\"}"
"$BAO/v1/auth/gitlab/login" | jq -r .auth.client_token)
- DB_PASSWORD=$(curl -fsS --cacert "$CI_SERVER_TLS_CA_FILE"
-H "X-Vault-Token: $BAO_TOKEN" "$BAO/v1/kv/data/ci/myapp/db" | jq -r .data.data.password)
- echo "got a database password of ${#DB_PASSWORD} characters"
# ... deploy with $DB_PASSWORD ...Code language: PHP (php)
Protect main (section 15) so only maintainers can push there. That turns “the job runs on protected main of infra/myapp” into “a maintainer of that project approved this code”, which is exactly what the OpenBao role checks.
Nothing secret is stored in GitLab anymore. Every login shows up in OpenBao’s audit log with the project, branch and job.
15. Signed commits and protected branches
Protect the default branch in every project, or set it once per group under Settings → Repository → Default branch protection:
- Allowed to merge: Maintainers
- Allowed to push and merge: No one
- Allowed to force push: off
Changes to main then only come through merge requests.
SSH-signed commits show a Verified badge, so a commit that claims to be from you really is. Git signs with the SSH key you already have, no GPG needed:
git config --global gpg.format ssh
git config --global user.signingkey ~/.ssh/id_ed25519.pub
git config --global commit.gpgsign true
git config --global tag.gpgsign trueCode language: PHP (php)
In GitLab, add the same public key under User settings → SSH keys with Usage type: Authentication & Signing. The commit e-mail must be one of your verified GitLab e-mail addresses, which with SSO is the address from authentik.
16. Monitoring with your Prometheus
16.1 Scrape
/etc/prometheus/scrape.d/gitlab.yml:
scrape_configs:
- job_name: gitlab-rails
scheme: https
metrics_path: /-/metrics
tls_config:
ca_file: /etc/prometheus/mydomain-ca.crt
static_configs:
- targets: ['gitlab.mydomain.local']
- job_name: gitlab
static_configs:
- targets: ['10.20.0.100:9168']
labels: { component: gitlab-exporter }
- targets: ['10.20.0.100:9229']
labels: { component: workhorse }
- targets: ['10.20.0.100:8082']
labels: { component: sidekiq }
- targets: ['10.20.0.100:9236']
labels: { component: gitaly }
- targets: ['10.20.0.100:9121']
labels: { component: redis }
- targets: ['10.20.0.100:9187']
labels: { component: postgres }
- targets: ['10.20.0.100:5001']
labels: { component: registry }
- job_name: gitlab-runner
static_configs:
- targets: ['10.20.0.101:9252']Code language: JavaScript (javascript)
/-/metrics answers only to the addresses in monitoring_whitelist. The runner exposes metrics once you add listen_address = "10.20.0.101:9252" at the top of its config.toml.
16.2 The backup-age metric
The backup script in section 18 writes a timestamp for node_exporter’s textfile collector. One rule then catches every way a backup can fail: the timer didn’t run, the script crashed, the disk was full.
16.3 Alert rules
/etc/prometheus/rules/gitlab.yml:
groups:
- name: gitlab
rules:
- alert: GitLabTargetDown
expr: up{job=~"gitlab.*"} == 0
for: 5m
labels:
severity: critical
annotations:
summary: "GitLab target {{ $labels.job }} {{ $labels.component }} is not answering"
- alert: GitLabHigh5xx
expr: |
sum(rate(gitlab_workhorse_http_requests_total{code=~"5.."}[5m]))
/ sum(rate(gitlab_workhorse_http_requests_total[5m])) > 0.05
for: 10m
labels:
severity: warning
annotations:
summary: "More than 5% of GitLab requests fail with 5xx"
- alert: GitLabSidekiqBacklog
expr: max(sidekiq_queue_latency_seconds) > 300
for: 15m
labels:
severity: warning
annotations:
summary: "Sidekiq jobs wait more than 5 minutes: mails, pipelines and webhooks are late"
- alert: GitLabBackupTooOld
expr: time() - gitlab_backup_last_success_timestamp_seconds > 30 * 3600
for: 30m
labels:
severity: critical
annotations:
summary: "No successful GitLab backup for more than 30 hours"
- alert: GitLabDataDiskFilling
expr: |
node_filesystem_avail_bytes{instance=~"gitlab.*",mountpoint="/var/opt/gitlab"}
/ node_filesystem_size_bytes{instance=~"gitlab.*",mountpoint="/var/opt/gitlab"} < 0.15
for: 30m
labels:
severity: warning
annotations:
summary: "Less than 15% free on /var/opt/gitlab"
- alert: GitLabRunnerDown
expr: up{job="gitlab-runner"} == 0
for: 10m
labels:
severity: warning
annotations:
summary: "runner-01 is not answering: pipelines are stuck as pending"Code language: JavaScript (javascript)
Adjust the instance matcher to how your node_exporter targets are named.
docker run --rm -v /etc/prometheus:/etc/prometheus:ro --entrypoint promtool \
quay.io/prometheus/prometheus:v3.13.5 check config /etc/prometheus/prometheus.yml
docker run --rm -v /etc/prometheus:/etc/prometheus:ro --entrypoint promtool \
quay.io/prometheus/prometheus:v3.13.5 check rules /etc/prometheus/rules/gitlab.yml
cd /opt/compose/monitoring && docker compose kill -s SIGHUP prometheusCode language: JavaScript (javascript)
For dashboards, GitLab publishes its own Grafana dashboards in the gitlab-org/grafana-dashboards project. Import the omnibus ones and point them at your Prometheus data source.
17. Firewall
/etc/nftables.d/gitlab.nft on the GitLab VM:
destroy table inet gitlab
table inet gitlab {
set staff_v4 { type ipv4_addr; flags interval; elements = { 10.10.0.0/16 } }
set staff_v6 { type ipv6_addr; flags interval; elements = { 2001:db8:10::/48 } }
set runners_v4 { type ipv4_addr; elements = { 10.20.0.101 } }
set runners_v6 { type ipv6_addr; elements = { 2001:db8:20::101 } }
chain input {
type filter hook input priority filter - 10; policy accept;
iif "lo" accept
ct state established,related accept
# Web, Git over HTTPS, registry
tcp dport { 80, 443 } ip saddr @staff_v4 accept
tcp dport { 80, 443 } ip6 saddr @staff_v6 accept
tcp dport { 80, 443 } ip saddr @runners_v4 accept
tcp dport { 80, 443 } ip6 saddr @runners_v6 accept
# Git over SSH (and admin SSH)
tcp dport 22 ip saddr @staff_v4 accept
tcp dport 22 ip6 saddr @staff_v6 accept
# Exporters, Prometheus only
tcp dport { 9168, 9229, 8082, 9236, 9121, 9187, 5001 } ip saddr 10.20.0.90 accept
tcp dport { 9168, 9229, 8082, 9236, 9121, 9187, 5001 } ip6 saddr 2001:db8:20::90 accept
tcp dport { 22, 80, 443, 9168, 9229, 8082, 9236, 9121, 9187, 5001 } counter drop
}
}Code language: PHP (php)
nft -c -f /etc/nftables.d/gitlab.nft && nft -f /etc/nftables.d/gitlab.nft
On the runner VM, only SSH from staff and 9252 from Prometheus come in. The runner only makes outbound connections: to GitLab, the registry, OpenBao, and the image and package mirrors your jobs pull from.
Outbound from the GitLab VM needs: authentik (443), the mail relay (587), packages.gitlab.com for upgrades, and whatever your webhooks call.
18. Backups and a restore test

18.1 What goes where
| Item | In gitlab-backup? | Where it’s kept |
|---|---|---|
| Database, repositories, uploads, CI artifacts, LFS, registry, packages | Yes | /var/opt/gitlab/backups/*_gitlab_backup.tar, copied off the VM |
/etc/gitlab/gitlab-secrets.json | No | OpenBao (kv/gitlab/secrets-json), section 6 |
/etc/gitlab/gitlab.rb, instance-settings.rb | No | Git |
/etc/gitlab/secrets/* | No | OpenBao (kv/gitlab/app) |
/etc/gitlab/ssl/* | No | Your CA can reissue; or the config backup below |
/etc/ssh/ssh_host_* | No | The config backup below, so developers don’t see a host key warning after a restore |
The split is deliberate. A stolen backup archive without gitlab-secrets.json doesn’t reveal CI variables, 2FA secrets or runner tokens.
18.2 Nightly backup
/usr/local/sbin/gitlab-backup-nightly:
#!/bin/bash
set -euo pipefail
TEXTFILE_DIR=/var/lib/prometheus/node-exporter # your node_exporter's textfile directory
/opt/gitlab/bin/gitlab-backup create CRON=1 STRATEGY=copy
# SSH host keys and certificates, root-only
umask 077
tar -czf "/var/opt/gitlab/backups/gitlab-host-config-$(date +%F).tar.gz" \
/etc/ssh/ssh_host_* /etc/gitlab/ssl
find /var/opt/gitlab/backups -name 'gitlab-host-config-*.tar.gz' -mtime +7 -delete
# Tell Prometheus
printf 'gitlab_backup_last_success_timestamp_seconds %s\n' "$(date +%s)" \
> "$TEXTFILE_DIR/gitlab_backup.prom.$$"
mv "$TEXTFILE_DIR/gitlab_backup.prom.$$" "$TEXTFILE_DIR/gitlab_backup.prom"Code language: PHP (php)
/etc/systemd/system/gitlab-backup.service:
[Unit]
Description=GitLab nightly backup
After=gitlab-runsvdir.service
[Service]
Type=oneshot
ExecStart=/usr/local/sbin/gitlab-backup-nightly
Nice=10
IOSchedulingClass=idleCode language: JavaScript (javascript)
/etc/systemd/system/gitlab-backup.timer:
[Unit]
Description=GitLab nightly backup at 02:15
[Timer]
OnCalendar=*-*-* 02:15
Persistent=true
[Install]
WantedBy=timers.targetCode language: JavaScript (javascript)
chmod 750 /usr/local/sbin/gitlab-backup-nightly
systemctl daemon-reload && systemctl enable --now gitlab-backup.timer
systemctl start gitlab-backup.service && ls -lh /var/opt/gitlab/backupsCode language: JavaScript (javascript)
backup_keep_time = 604800ingitlab.rbkeeps seven days of archives locally. Your backup system copies/var/opt/gitlab/backupsoff the VM and keeps the long history.STRATEGY=copycopies files before archiving them, so files changing during the backup don’t maketarfail.- A large registry makes every archive large. If that hurts, add
SKIP=registryand back up/var/opt/gitlab/gitlab-rails/shared/registrywith your file backup instead.
18.3 Restore test, once
On a fresh Debian 13 VM with the same name:
- Sections 3 to 6, with exactly the same GitLab version as the backup. A backup only restores into the version that made it.
- Put
gitlab-secrets.jsonback from OpenBao before the restore:
bao kv get -field=json kv/gitlab/secrets-json > /etc/gitlab/gitlab-secrets.json
chmod 600 /etc/gitlab/gitlab-secrets.json
gitlab-ctl reconfigureCode language: JavaScript (javascript)
- Restore the archive:
cp 1796450000_2026_12_05_19.6.2_gitlab_backup.tar /var/opt/gitlab/backups/
chown git:git /var/opt/gitlab/backups/*_gitlab_backup.tar
gitlab-ctl stop puma
gitlab-ctl stop sidekiq
gitlab-backup restore BACKUP=1796450000_2026_12_05_19.6.2
gitlab-ctl reconfigure
gitlab-ctl restartCode language: JavaScript (javascript)
- Put the old SSH host keys back from the host-config archive and reload
ssh. - Check:
gitlab-rake gitlab:check SANITIZE=true
gitlab-rake gitlab:doctor:secrets # every encrypted value can be decryptedCode language: PHP (php)
- Log in through authentik, clone a repository over SSH, run a pipeline that reads a CI variable, pull an image from the registry.
gitlab:doctor:secrets is the test that matters. If it reports values it can’t decrypt, gitlab-secrets.json doesn’t belong to this database, and CI variables and runner tokens are lost.
19. Upgrades
GitLab is strict about the order of upgrades. Some releases are required stops: you must install them, and let their background migrations finish, before going further. Skipping a stop can leave the database half migrated.
- Plan the path with the upgrade path tool at
https://gitlab-com.gitlab.io/support/toolbox/upgrade-path/: enter your version and the target, and it lists every stop. - Read the release notes and deprecations for each version on the path.
- Check that background migrations are done (also under Admin → Monitoring → Background migrations):
gitlab-rails runner -e production 'puts Gitlab::Database::BackgroundMigration::BatchedMigration.queued.count' # 0Code language: PHP (php)
- Back up (section 18). The package also takes a database backup automatically before it upgrades.
- Upgrade one stop at a time:
apt update && apt-cache madison gitlab-ce | head -n 5
apt-mark unhold gitlab-ce
apt install gitlab-ce=19.6.3-ce.0 # example: the next version on the path
apt-mark hold gitlab-ce
gitlab-rake gitlab:check SANITIZE=trueCode language: PHP (php)
- Wait for the background migrations of that version to reach 0 before the next stop.
- Save
gitlab-secrets.jsonto OpenBao again if it changed:
sha256sum /etc/gitlab/gitlab-secrets.json
bao kv put kv/gitlab/secrets-json json=@/etc/gitlab/gitlab-secrets.json
- Upgrade the runner to the same version afterwards.
Patch releases (19.6.2 to 19.6.3) are quick and safe; install them promptly, they’re often security fixes. Subscribe to GitLab’s security release notices.
Rollback isn’t a package downgrade: database migrations can’t be undone. Rollback means a new VM with the old version and the last backup (section 18.3). That’s one more reason to test the restore before you need it.
20. Troubleshooting
| Symptom | Cause and fix |
|---|---|
SSO login: SSL_connect ... certificate verify failed | authentik’s CA isn’t in /etc/gitlab/trusted-certs/; copy it there and run gitlab-ctl reconfigure |
| authentik says “Permission denied” | The user isn’t in gitlab-users; that’s the binding doing its job |
| authentik: “Redirect URI Error” | The redirect URI in authentik doesn’t match https://gitlab.mydomain.local/users/auth/openid_connect/callback exactly |
| GitLab: “Could not authenticate you from OpenIDConnect” | Wrong client secret or issuer; the issuer must end with /application/o/gitlab/ |
| SSO creates a second account for an existing user | The local account wasn’t linked first (section 7.3); merge by deleting the new empty one and linking |
| Can’t reach the password form | Automatic sign-in: use /users/sign_in?auto_sign_in=false; if password login is off, see section 7.4 |
ssh -T git@... asks for a password | AuthorizedKeysCommand not active (sshd -T -C user=git shows the effective config), or the key isn’t in GitLab |
| A user left but still pushes over SSH | Not blocked in GitLab: check journalctl -u gitlab-offboard and the authentik token’s expiry |
Job: x509: certificate signed by unknown authority | tls-ca-file missing in config.toml, or the job’s tool doesn’t use CI_SERVER_TLS_CA_FILE |
BuildKit: operation not permitted | BUILDKITD_FLAGS=--oci-worker-no-process-sandbox missing, or the image isn’t the rootless variant |
OpenBao login: claim "ref_protected" does not match | The job ran on an unprotected branch: protect it, or it’s working as intended |
OpenBao login: audience claim does not match | aud in id_tokens differs from bound_audiences |
| Pipelines stay pending | Runner down or not matching tags; Admin → CI/CD → Runners shows when it last contacted GitLab |
Prometheus: 404 or 403 on /-/metrics | Prometheus’s address isn’t in monitoring_whitelist, or it scrapes over IPv6 and only the IPv4 address is listed |
| Webhook: “Requests to the local network are not allowed” | Section 8: allow just that host under outbound requests |
gitlab:doctor:secrets reports failures after a restore | Wrong gitlab-secrets.json; restore the one from OpenBao that belongs to this database |
| 502 for a few minutes after a restart | Puma is still starting; gitlab-ctl tail puma shows progress |
Useful:
gitlab-ctl status
gitlab-ctl tail # all logs; or: gitlab-ctl tail nginx / puma / sidekiq / gitaly
gitlab-rake gitlab:check SANITIZE=true
gitlab-rake gitlab:env:info
gitlab-rails console # careful: full database accessCode language: PHP (php)
21. Checklist
- ☐ GitLab CE from
packages.gitlab.comas a deb822 source; version pinned and held; same version for the runner - ☐ Repositories and backups on separate disks
- ☐ Internal CA in
/etc/gitlab/trusted-certs/; TLS 1.2 and 1.3 only; HSTS on - ☐ Secrets in OpenBao and in root-only files;
gitlab.rbcontains none and lives in Git - ☐
gitlab-secrets.jsonin OpenBao after install and after every upgrade - ☐ authentik provider with strict redirect URI, hashed-ID subject,
gitlab-usersbinding - ☐ Your account made admin with the break-glass
root;rootpassword in OpenBao only - ☐
instance-settings.rbapplied: no sign-ups, no passwords, admin mode, nothing public, no local webhooks, dormant users deactivated - ☐ Offboarding sync on a timer, tested with a deactivated test user
- ☐ SSH fast lookup working,
authorized_keysdisabled and empty - ☐ Registry with cleanup policies and monthly garbage collection
- ☐ Runner on its own VM: unprivileged, no Docker socket, memory and CPU limits, weekly prune
- ☐ Pipelines build with rootless BuildKit, scan with Trivy, images pinned
- ☐ Deploy jobs get secrets from OpenBao with ID tokens, bound to project and protected branch
- ☐ Default branch protected; SSH commit signing set up
- ☐ Prometheus scrapes GitLab, the runner and node_exporter; alert rules loaded, backup-age alert included
- ☐ nftables: web and SSH from staff and runners, exporters from Prometheus only
- ☐ Nightly backup with host keys; restore test passed including
gitlab:doctor:secrets - ☐ Upgrades along the upgrade path, background migrations at 0 before each stop