The Simplest Way to Make Gitea and Longhorn Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Running gitea and longhorn together gives your code host safe storage inside Kubernetes. Gitea manages Git repos and issues, while Longhorn keeps that data safe across nodes. This setup stops data loss when a pod restarts or a node fails. Your team gets a fast code host backed by redundant block storage. How gitea and longhorn share data and roles Gitea needs a place to write Git objects, avatars, and site attachments. It also needs a database to store user accounts, pull requests, and issue

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

Running gitea and longhorn together gives your code host safe storage inside Kubernetes. Gitea manages Git repos and issues, while Longhorn keeps that data safe across nodes.

This setup stops data loss when a pod restarts or a node fails. Your team gets a fast code host backed by redundant block storage.

How gitea and longhorn share data and roles

Gitea needs a place to write Git objects, avatars, and site attachments. It also needs a database to store user accounts, pull requests, and issue comments. In Kubernetes, pods lose their local files as soon as they stop or move.

Longhorn fixes this problem by creating persistent volumes across your cluster nodes. You define a storage claim in your cluster for the Gitea app. The cluster passes this claim to the Longhorn driver to make a new volume. Longhorn then mounts that block volume into the Gitea pod at start time.

Permissions flow through Kubernetes service accounts and storage classes. The Gitea pod runs under a specific user ID and group ID. It needs read and write rights on the mounted path to save new commits. Longhorn uses its own system service account to talk to the Kubernetes API. This role lets it attach disks, copy blocks across nodes, and run volume snapshots.

Common failure modes and how to scope roles

Many teams hit trouble when two Gitea pods try to mount one volume. Standard block storage only lets one node mount a volume at a time. If a node hangs, the new pod waits while the old lock clears. Using shared service accounts with broad cluster admin rights creates another big risk. If an attacker breaks into the code host, broad tokens expose the storage API.

Unlogged queries to the Gitea database or storage API also hide bad actions. You cannot tell which user changed a volume setting or read private repo data. You should fix this by scoping roles down to the bare minimum. Give the Gitea service account rights only within its own namespace. Never let the app pod talk to the Longhorn manager API directly.

End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Set up network rules so only storage nodes talk on replication ports. Put the Gitea database on its own volume with separate backup schedules. Keep your admin tokens narrow and rotate them on a set schedule. Log every admin login to both the Git interface and the storage dashboard. If the database holds sensitive emails or phone numbers, mask those fields in logs.

Backup and recovery workflows for Git storage

Disk replication keeps your app online during a single node crash. Yet replication alone does not count as a real backup plan. If a user deletes a repo by mistake, Longhorn deletes it on all replicas.

You need off-cluster snapshots to recover from bad deletes or cluster failures. Longhorn can take point-in-time snapshots of your volume and send them to object storage. Before a snapshot runs, make sure the Gitea database flushes its open writes. This step keeps the Git file system and database records in sync.

Test your restore flow on a spare namespace every month. Mount a backup volume to a test pod and check the Git history. Good backups let your team upgrade the app with zero fear of data loss.

Govern statements and responses across databases and APIs

Good config and scoped roles are needed setup. They do not check single queries in flight or mask sensitive fields in returned rows. Across Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, and internal HTTP endpoints, hoop.dev runs beside each supported service as an open-source proxy, a sidecar for your database or API.

First, hoop.dev guardrails block banned queries before they run. Then hoop.dev data masking rewrites matched sensitive values in responses in memory. The audit trail records every statement and verdict per resource. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.

Frequently asked questions

Can multiple Gitea pods share a single Longhorn volume?

A standard block volume binds to one node at a time. To run multiple pods, you must enable shared filesystem mode in Longhorn.

Should the Gitea database share a volume with Git repositories?

No, you should give the database and the Git files separate volumes. This split lets you tune snapshot times and disk sizes for each workload.

How do I fix file permission errors on a mounted volume?

Set the security context in your pod spec to match the Gitea user ID. Kubernetes will then set the right folder owner when it mounts the disk.

The query runs. The emails stay hidden.