Self-Hosted Git on Kubernetes — Deploying Forgejo on K8s

 

If you are coming from a VMware background and building a Kubernetes homelab, one of the first things you will want is a place to store your YAML files, Helm values, and scripts. This post covers deploying Forgejo — a lightweight self-hosted Git server — on a K3s cluster using Helm and local-path storage.

What is Forgejo?

Forgejo is a community-driven fork of Gitea. It gives you a GitHub-like interface for hosting your own Git repositories, with no external dependencies and a tiny footprint. For a homelab running Kubernetes configs and scripts, it is exactly what you need.

Think of it like having your own internal GitLab, but without the heavyweight resource requirements.

Prerequisites

  • K3s cluster running (this lab uses k3s-cp-01 at 172.16.77.10)
  • Helm installed
  • local-path storage class available

Install Forgejo via Helm

Forgejo publishes its own OCI Helm chart. No repo add needed — you pull directly from the registry.

helm install my-forgejo oci://code.forgejo.org/forgejo-helm/forgejo \
  --version 16.2.1 \
  --namespace git \
  --create-namespace \
  --set global.storageClass=local-path \
  --set persistence.size=2Gi \
  --set service.http.type=NodePort \
  --set service.http.nodePort=30040

Key flags explained:

  • global.storageClass=local-path — tells the chart to use K3s built-in local storage
  • persistence.size=2Gi — 2GB is plenty for YAML and scripts in a homelab
  • service.http.type=NodePort — exposes the UI on a fixed port without needing an ingress controller
  • service.http.nodePort=30040 — the port you will access the UI on

Verify the Install

kubectl get pods -n git
NAME           READY   STATUS    RESTARTS   AGE
my-forgejo-0   1/1     Running   0          65m
kubectl get svc -n git
NAME              TYPE       CLUSTER-IP      PORT(S)
my-forgejo-http   NodePort   10.43.112.170   3000:30040/TCP
my-forgejo-ssh    ClusterIP  10.43.66.25     22/TCP

Check the PVC was created and bound:

kubectl get pvc -n git
NAME         STATUS   CAPACITY   STORAGECLASS
my-forgejo   Bound    2Gi        local-path

Access the UI

Open a browser and go to:

http://172.16.77.10:30040

Complete the initial setup wizard. Create your admin account and you are ready to go.

Push Your First Repo

mkdir ~/homelab
cd ~/homelab
git init
git switch -c main
git add .
git commit -m "first commit"
git remote add origin http://172.16.77.10:30040/awk/homelab.git
git push -u origin main

What We Store Here

In this lab the homelab repository is structured by Kubernetes namespace:

homelab/
  dns/          # Technitium DNS configs
  database/     # PostgreSQL Helm values
  homepage/     # Homepage dashboard configmap
  monitoring/   # Uptime Kuma
  reader/       # Miniflux RSS reader
  git/          # Forgejo itself
  scripts/      # Lab control scripts
  docs/         # Session notes and cheatsheets

Every namespace folder has a README with the exact Helm install command and PVC details so the cluster can be rebuilt from scratch in minutes.

 

Summary

In the next post we will look at deploying ArgoCD and using Forgejo as the GitOps source of truth for the cluster.

(Visited 6 times, 1 visits today)

By Ash Thomas

Ash Thomas is a seasoned IT professional with extensive experience as a technical expert, complemented by a keen interest in blockchain technology.