← logbuild #27 passed0c2318d
Self-Host GitLab EE on K3s with Cloudflare Tunnel
A full homelab setup for GitLab EE on a single-node K3s VM. It covers split-horizon DNS, Cloudflare Tunnel, ARM64 image fixes, and the traps the official chart docs do not mention.
· 16 min read
The official GitLab Helm chart is made for production. It expects 8 vCPU, 30 GB RAM, many nodes, a registry on its own subdomain, and ports 80/443 open to the internet. A homelab on a Mac Mini cannot offer any of that. You want three things:
- One URL that works the same on LAN (your home network) and WAN (the internet)
- Zero inbound ports on the home router
- A setup that fits in 6 vCPU / 12 GB and still leaves the machine usable
This post shows the real working configuration. It runs K3s on a Debian 13 ARM64 VM, with Traefik + cloudflared + cert-manager and Pi-hole split-horizon DNS. It also covers four traps that the docs do not mention. Each one can cost you hours if you do not expect it.
In Simple Words#
- The problem
- You want to run GitLab at home on one small VM. The official Helm chart expects a much bigger production cluster and open ports to the internet.
- The root cause
- The chart’s defaults are made for production: 8 vCPU, 30 GB RAM, many nodes and amd64 images. A 12 GB ARM64 VM with its own hostname breaks several of these defaults.
- The solution
- Turn off the optional parts so GitLab fits. Use Pi-hole DNS for the direct path at home, and a Cloudflare Tunnel for the path from outside. Then fix four traps: two old MinIO images, the hostname, and the homepage error.
- Think of it like this
- Your house has one address but two ways in. People who are already inside walk straight to the room. Visitors from outside come through a guarded corridor that you opened from the inside, so the front door stays locked.
What You’ll Cover#
- The architecture: what runs where, and which path each request takes
- How to get a certificate with DNS-01, cert-manager and a Cloudflare API token
- Split-horizon DNS on Pi-hole, so LAN traffic does not go out to Cloudflare and back
- Cloudflared as a Deployment inside the cluster, with no port forwarding at all
- A minimal
values.yamlthat runs on a 12 GB VM - ARM64 image overrides for both the MinIO server and the
mcclient - The hostname override the chart needs when your hostname isn’t
gitlab.<domain> - The GitLab Duo homepage error 500 on fresh installs, and how to get around it
Architecture#
- Two clients want
gitlab.example.com. One is at home on the LAN. One is outside, on the internet. - The LAN client asks Pi-hole for the name. Pi-hole answers with the VM’s LAN IP,
192.168.1.20. - The LAN client connects straight to Traefik on the VM. Traefik passes the request to GitLab. Nothing leaves the house.
- The
cloudflaredpod opens an outbound QUIC tunnel to Cloudflare. The home router opens no inbound port. - The remote client gets a Cloudflare address from public DNS. Its request goes through the tunnel to Traefik and GitLab.
Two request paths use the same hostname and the same Let’s Encrypt (LE) certificate:
- LAN client → Pi-hole returns the VM’s LAN IP → Traefik on the VM → GitLab. The request never goes out to the internet.
- Remote client → Cloudflare public DNS → Cloudflare edge → outbound QUIC tunnel → Traefik → GitLab. The cloudflared pod inside the cluster keeps this tunnel open. The home router never accepts an inbound connection.
One LE certificate covers gitlab.<your-domain>. cert-manager gets it with DNS-01 through the Cloudflare API. With DNS-01 you prove that you own the domain by writing a DNS record. So you need no HTTP-01, no open port 80, and no port forwarding.
Why This Stack#
Some of these choices look random. Each one has a reason:
| Decision | Reason |
|---|---|
| UTM, not OrbStack | OrbStack always uses its own 192.168.139.x bridge, so the VM can’t get a real LAN IP on 192.168.1.0/24. UTM supports real bridged networking, so the VM is one more machine on the LAN. |
| K3s, not k0s or minikube | Comes with Traefik + local-path-provisioner + ServiceLB already included. That is three fewer things to install. PVCs (storage volumes) are stored under /var/lib/rancher/k3s/storage/. |
| DNS-01, not HTTP-01 | The VM does not have to be reachable on port 80 from the internet. The Cloudflare API token only needs Zone:Read + DNS:Edit on the zone. |
| Cloudflare Tunnel, not port forward | No inbound ports on the home router. The tunnel is an outbound QUIC connection from inside the cluster to Cloudflare’s edge. It goes the same direction as any other outgoing traffic. |
| MinIO bundled, registry off | GitLab needs object storage for artifacts/uploads/LFS. The Container Registry is optional. Pull images from Docker Hub or GHCR, and you can skip a second hostname and Ingress. |
Prerequisites#
- A running K3s cluster, where
kubectl get nodesshowsReady - A domain on Cloudflare (this post uses
example.com) - A Pi-hole at
192.168.1.2where you can add local DNS records - At least 50 GB free under
/var/lib/rancher/k3s/storage/
Install Helm (the package manager for Kubernetes) and add the GitLab chart:
curl -fsSL https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
helm repo add gitlab https://charts.gitlab.io/
helm repo updateDNS-01 with cert-manager#
Create a Cloudflare API token. Give it Zone:Read + DNS:Edit on your zone only, and nothing else. Store it as a secret:
kubectl create namespace cert-manager
kubectl create secret generic cloudflare-api-token \
--namespace cert-manager \
--from-literal=api-token='<paste-token>'Install cert-manager and apply a ClusterIssuer. The ClusterIssuer tells cert-manager where and how to get certificates:
helm repo add jetstack https://charts.jetstack.io
helm install cert-manager jetstack/cert-manager \
--namespace cert-manager --create-namespace \
--set crds.enabled=trueapiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
name: letsencrypt-cloudflare
spec:
acme:
server: https://acme-v02.api.letsencrypt.org/directory
email: [email protected]
privateKeySecretRef:
name: letsencrypt-cloudflare-account-key
solvers:
- dns01:
cloudflare:
apiTokenSecretRef:
name: cloudflare-api-token
key: api-token
selector:
dnsZones: ["example.com"]Create the Certificate before you install GitLab. Then the secret already exists when the Ingress starts:
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: gitlab-tls
namespace: gitlab
spec:
secretName: gitlab-tls
issuerRef:
name: letsencrypt-cloudflare
kind: ClusterIssuer
commonName: gitlab.example.com
dnsNames:
- gitlab.example.com
privateKey:
algorithm: ECDSA
size: 256
duration: 2160h # 90d
renewBefore: 360h # 15dkubectl create namespace gitlab
kubectl apply -f gitlab-tls-cert.yaml
kubectl -n gitlab get certificate gitlab-tls -w
# wait for READY=True (typically 30–120s)Split-Horizon DNS on Pi-hole#
Split-horizon DNS means that one name gets a different answer at home and outside. Most homelab guides skip this part. Without it, every LAN request to gitlab.example.com takes the long way. It goes out through your ISP, into Cloudflare, back through the tunnel, and into your VM. That is three hops to reach a machine that stands six feet from your desk.
The fix is one local DNS record. On the Pi-hole at 192.168.1.2, go to Settings → Local DNS Records → Add:
Domain: gitlab.example.com
IP: 192.168.1.20 (your K3s VM's LAN IP)The same record as dnsmasq config:
address=/gitlab.example.com/192.168.1.20Reload with pihole restartdns. Check from a LAN client:
dig @192.168.1.2 gitlab.example.com +short
# expected: 192.168.1.20 (NOT a Cloudflare anycast address)Cloudflared in the Cluster#
Run these three setup commands once, from any machine that has cloudflared installed. A workstation is fine. The binary does not need to be on the K3s VM:
cloudflared tunnel login
cloudflared tunnel create gitlab-homelab
cloudflared tunnel route dns gitlab-homelab gitlab.example.comThe create command writes credentials to ~/.cloudflared/<uuid>.json. Load them into the cluster:
kubectl -n gitlab create secret generic cloudflared-credentials \
--from-file=credentials.json=$HOME/.cloudflared/<tunnel-uuid>.jsonDeploy cloudflared as a normal Kubernetes Deployment. It points at the Traefik service inside the cluster:
apiVersion: v1
kind: ConfigMap
metadata:
name: cloudflared-config
namespace: gitlab
data:
config.yaml: |
tunnel: <tunnel-uuid>
credentials-file: /etc/cloudflared/creds/credentials.json
ingress:
- hostname: gitlab.example.com
service: https://traefik.kube-system.svc.cluster.local:443
originRequest:
originServerName: gitlab.example.com # MUST match a SAN on gitlab-tls
- service: http_status:404
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: cloudflared
namespace: gitlab
spec:
replicas: 1
selector:
matchLabels: { app: cloudflared }
template:
metadata:
labels: { app: cloudflared }
spec:
containers:
- name: cloudflared
image: cloudflare/cloudflared:latest
args: ["tunnel", "--config", "/etc/cloudflared/config/config.yaml", "run"]
volumeMounts:
- { name: config, mountPath: /etc/cloudflared/config, readOnly: true }
- { name: creds, mountPath: /etc/cloudflared/creds, readOnly: true }
volumes:
- { name: config, configMap: { name: cloudflared-config } }
- { name: creds, secret: { secretName: cloudflared-credentials } }kubectl apply -f cloudflared.yaml
kubectl -n gitlab logs deploy/cloudflared
# expect: "Registered tunnel connection" lines, one per CF edgeIn the Cloudflare dashboard, set the public hostname to proxied (orange cloud). Cloudflare ends the TLS connection at its edge with its own certificate. Then the tunnel encrypts the traffic again on the way to Traefik. Traefik shows the LE certificate inside the cluster. That’s why originServerName must match a SAN (a name listed in the certificate) on gitlab-tls. If it does not, Traefik’s SNI matching finds no match and serves the wrong certificate.
The Minimal values.yaml#
Save this as gitlab-values.yaml. It turns off everything optional, so GitLab can run on the 12 GB VM:
global:
edition: ee
hosts:
domain: example.com
# gitlab:
# name: gitlabee.example.com # uncomment if your prefix isn't `gitlab.`
https: true
ingress:
configureCertmanager: false
class: traefik
tls:
enabled: true
secretName: gitlab-tls
initialRootPassword:
secret: gitlab-initial-root-password
key: password
kas:
enabled: false
nginx-ingress:
enabled: false
prometheus:
install: false
gitlab-runner:
install: false
installCertmanager: false
registry:
enabled: false
gitlab:
webservice:
minReplicas: 1
maxReplicas: 1
resources:
requests: { cpu: 400m, memory: 2.5Gi }
sidekiq:
minReplicas: 1
maxReplicas: 1
resources:
requests: { cpu: 200m, memory: 1Gi }
gitaly:
persistence:
storageClass: local-path
size: 20Gi
postgresql:
persistence: { storageClass: local-path, size: 8Gi }
redis:
master:
persistence: { storageClass: local-path, size: 5Gi }
minio:
image: quay.io/minio/minio
imageTag: RELEASE.2025-09-07T16-13-09Z
imagePullPolicy: IfNotPresent
minioMc:
image: quay.io/minio/mc
tag: RELEASE.2025-09-07T16-02-50Z
ingress:
enabled: false
persistence: { storageClass: local-path, size: 20Gi }Create the root password secret first, so you don’t have to search for it later:
kubectl create secret generic gitlab-initial-root-password \
--namespace gitlab \
--from-literal=password='ChangeMe-Strong-Password!'Install:
helm install gitlab gitlab/gitlab \
--namespace gitlab \
--values gitlab-values.yaml \
--timeout 600s
kubectl -n gitlab get pods -wThe first install pulls several GB of images and runs database migrations. On a 6 vCPU ARM64 VM, plan for 15–20 minutes before gitlab-webservice-default-* is 2/2 Running.
Four Traps That Can Cost You Hours#
Everything above works on x86 with the default hostname. The four problems below appear on ARM64, with a non-default hostname, or on a fresh install.
ARM64 #1: The MinIO Server Image#
GitLab’s chart includes a MinIO subchart for object storage. It is fixed to RELEASE.2017-12-28T01-21-00Z, an amd64-only image from 2017. On ARM64 the pod fails with exec format error and never starts.
The fix is in the minio block above:
minio:
image: quay.io/minio/minio
imageTag: RELEASE.2025-09-07T16-13-09Zquay.io/minio/minio is multi-arch: one image name works on more than one CPU type. The chart sets the env vars MINIO_ACCESS_KEY / MINIO_SECRET_KEY. Current MinIO still accepts them as old names for MINIO_ROOT_USER / MINIO_ROOT_PASSWORD. So the credentials keep working, and you change nothing else.
ARM64 #2: The MinIO mc Client Image#
This one is not in the official chart docs. The chart uses a separate fixed image for the mc client. The gitlab-minio-create-buckets Job runs this client:
registry.gitlab.com/gitlab-org/cloud-native/mirror/images/minio/mc:RELEASE.2018-07-13T00-53-22ZThis is an amd64-only image from 2018. On ARM64 the Job loops in CrashLoopBackOff, with three clear signs:
- Exit code 255
- Pod starts and exits in the same second
kubectl logs … --previousreturnsunable to retrieve container logs
The buckets are never created. So GitLab returns 500 on any page that uses object storage. That is most pages, including /dashboard/home. The webservice pods are 2/2 Running, the certificate is valid, and the tunnel is green on the Cloudflare dashboard. Everything looks fine, but nothing works.
The fix is the minioMc block in values.yaml above:
minio:
minioMc:
image: quay.io/minio/mc
tag: RELEASE.2025-09-07T16-02-50ZAfter a helm upgrade, make the Job run again with the new image:
kubectl -n gitlab delete job -l component=create-buckets
kubectl -n gitlab get pods -l component=create-buckets -w
# expect: CompletedThen restart webservice + sidekiq, so they find the buckets that now exist:
kubectl -n gitlab rollout restart \
deploy/gitlab-webservice-default \
deploy/gitlab-sidekiq-all-in-1-v2Hostname Prefix: Override global.hosts.gitlab.name#
By default the chart builds the GitLab hostname as gitlab.<global.hosts.domain>. Say you set domain: example.com and point the tunnel at gitlabee.example.com (or git.example.com, or any name without the gitlab. prefix). Then Traefik gets an Ingress for the default name only. The tunnel returns 404 page not found on the hostname you really use.
The Cloudflare dashboard is green. The certificate is valid. The webservice is healthy. But Traefik has no Ingress that matches the Host header.
global:
hosts:
domain: example.com
gitlab:
name: gitlabee.example.com # the actual hostname you serveVerify after helm upgrade:
kubectl -n gitlab get ingress
# HOSTS column must match the hostname in the cloudflared config AND the SAN on gitlab-tlsThe same hostname must be in three places: global.hosts.gitlab.name, the cloudflared ConfigMap’s hostname + originServerName, and the gitlab-tls Certificate’s dnsNames. If one of the three is different, at least one path breaks.
The Duo Homepage 500 on Fresh Install#
On a fresh GitLab 17.x+, the first visit to /dashboard/home makes the controller create an internal bot user called duo_code_review_bot. The bot is not created at install time, only at this first visit. On fresh installs, saving that bot can fail. The homepage needs the bot’s username to render, so the whole page returns 500. /api/v4/user_counts returns 500 for the same reason.
The stack trace looks like this:
app/controllers/dashboard_controller.rb:50:in `home'
app/controllers/concerns/homepage_data.rb:21:in `homepage_app_data'
app/controllers/concerns/homepage_data.rb:66:in `duo_code_review_bot_username'
lib/users/internal.rb:110:in `duo_code_review_bot'
lib/users/internal.rb:241:in `create_unique_internal'
state_machines (0.100.4) lib/state_machines/machine.rb:569:in `save'/dashboard/projects returns 200. So you are not locked out of GitLab. Only the new home view is broken.
The easiest way around it is to send users to the old dashboard:
For one user: Top-right avatar → Preferences → Homepage → Your Projects.
For the whole instance: Admin Area → Settings → Preferences → Navigation → Default dashboard → Your Projects.
To find the real root cause, run the same code in the Rails console. There the error prints clearly:
kubectl -n gitlab exec -it deploy/gitlab-toolbox -- gitlab-rails runner '
begin
u = Users::Internal.duo_code_review_bot
puts "OK: #{u.inspect}"
rescue => e
puts "FAILED: #{e.class}: #{e.message}"
puts e.record.errors.full_messages if e.respond_to?(:record)
end
'Common causes:
- An old row left by an earlier creation that stopped halfway
- Email validation against an allowlist
- A Duo setting that must be set first
When you have the validation error, the fix is usually one line.
Verify the End-to-End Path#
From a LAN device that uses Pi-hole as its DNS server:
dig gitlab.example.com +short
# → 192.168.1.20 (VM, not Cloudflare)
curl -vI https://gitlab.example.com 2>&1 | grep -E "(issuer|cf-ray|server:)"
# expected: issuer=Let's Encrypt, NO cf-ray headerFrom outside the LAN (mobile data):
dig gitlab.example.com +short
# → Cloudflare anycast
curl -vI https://gitlab.example.com 2>&1 | grep -E "(cf-ray|server:)"
# expected: cf-ray: <id>, server: cloudflareTunnel health:
kubectl -n gitlab logs deploy/cloudflared --tail=50
# expect: "Registered tunnel connection" lines, no repeating errorsCertificate:
kubectl -n gitlab get certificate gitlab-tls
# NAME READY SECRET AGE
# gitlab-tls True gitlab-tls 3mWhat You Have Now#
| Component | What it does |
|---|---|
| UTM + Debian 13 VM | Real LAN IP, ARM64 kernel, single-node K3s |
| K3s + Traefik | Single-binary Kubernetes with Ingress and storage included |
| cert-manager + DNS-01 | One LE certificate for your GitLab hostname, and port 80 stays closed |
| cloudflared Deployment | Outbound QUIC tunnel — zero inbound ports on the home router |
| Pi-hole local DNS | LAN clients reach the VM directly, with no trip out to Cloudflare and back |
| GitLab Helm chart (minimal) | EE image, Postgres + Redis + Gitaly + MinIO bundled, no registry/KAS/Prometheus/Runner |
| Single hostname | Same URL, same certificate, on LAN and WAN. No /etc/hosts edits needed |
The VM uses around 7–9 GB RAM at idle. The first boot takes 15–20 minutes. Later restarts take under a minute. Git over SSH works on the LAN (port 22 on the VM). From outside, use HTTPS with a Personal Access Token. Cloudflare Tunnel doesn’t expose plain SSH unless the client runs cloudflared access tcp.
Next Steps#
- Self-Host Harbor Image Registry on Debian — use GitLab with a separate container registry and leave GitLab’s built-in one off.
- The TLS Foundation — the bigger picture: why TLS ends where it does, and where cert-manager fits in.
- Fix Slow Self-Hosted GitLab: The RAM Trap — when GitLab feels slow on a machine with little RAM, this is usually the cause.
- Monitoring Proxmox with the Grafana Stack — when GitLab is up, watch it with Prometheus and find resource problems before your users do.