infra/home/cluster/forgejo
2025-10-06 09:17:32 -05:00
..
configmap-app.yaml updates 2025-09-06 10:55:13 -05:00
configmap.yaml updates 2025-10-06 09:17:32 -05:00
deployment.yaml update 2025-10-01 17:06:51 -05:00
ingress-tailscale-fixed.yaml update 2025-09-06 12:46:26 -05:00
ingress-tailscale.yaml update 2025-09-06 12:46:26 -05:00
ingress.yaml update 2025-10-01 17:06:51 -05:00
kustomization.yaml update 2025-10-01 17:06:51 -05:00
namespace.yaml update 2025-10-01 17:06:51 -05:00
pv-rbd.yaml updates 2025-09-06 10:55:13 -05:00
pv.yaml updates 2025-09-06 10:55:13 -05:00
pvc-rbd.yaml updates 2025-09-06 10:55:13 -05:00
pvc.yaml update 2025-10-01 17:06:51 -05:00
README.md update 2025-10-01 17:06:51 -05:00
secret.yaml updates 2025-10-05 13:12:28 -05:00
service-tailscale-https.yaml update 2025-09-06 12:46:26 -05:00
service-tailscale.yaml update 2025-10-01 17:06:51 -05:00
service.yaml update 2025-10-01 17:06:51 -05:00
setup-database-auto.sh update 2025-10-01 17:06:51 -05:00
setup-database.sh update 2025-10-01 17:06:51 -05:00

Forgejo Deployment on Home K3s Cluster

This deploys Forgejo (Git server) on the home k3s cluster using the existing MariaDB instance.

Prerequisites

  1. MariaDB is already running in the data namespace
  2. Longhorn storage class is available
  3. MetalLB is configured for LoadBalancer services

Setup Steps

1. Create Database

First, create the database and user in MariaDB:

# Run the setup script to see the commands
./setup-database.sh

# Connect to MariaDB
kubectl exec -it -n data deployment/mariadb -- mysql -u root -p

# Create database and user (update password!)
CREATE DATABASE IF NOT EXISTS forgejo CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER IF NOT EXISTS 'forgejo'@'%' IDENTIFIED BY 'your-secure-password';
GRANT ALL PRIVILEGES ON forgejo.* TO 'forgejo'@'%';
FLUSH PRIVILEGES;
EXIT;

2. Update Secrets

Edit secret.yaml and update:

  • database-password: Use the same password you set in MariaDB
  • secret-key: Generate a random 64-character string
  • internal-token: Generate a random 106-character string

You can generate random strings with:

# 64 characters
openssl rand -hex 32

# 106 characters  
openssl rand -hex 53

3. Deploy Forgejo

# Deploy all resources
kubectl apply -k .

# Check deployment status
kubectl get all -n git

# Watch the logs
kubectl logs -n git deployment/forgejo -f

4. Access Forgejo

Once the LoadBalancer gets an IP:

kubectl get svc -n git forgejo

Access Forgejo at:

  • Web UI: http://
  • Git SSH: ssh://git@:22/

5. Initial Setup

On first access:

  1. The initial setup page should show
  2. Database settings should be pre-filled
  3. Create your admin account
  4. Complete the setup

Configuration

The configuration is managed via ConfigMap. Key settings:

  • Domain: git.w5isp.com
  • SSH enabled on port 22
  • LFS (Large File Storage) enabled
  • Using MariaDB in the data namespace

Troubleshooting

Check logs:

kubectl logs -n git deployment/forgejo

Check database connection:

kubectl exec -n git deployment/forgejo -- nc -zv mariadb.data.svc.cluster.local 3306

Backup

Remember to backup:

  • The Longhorn PVC (forgejo-data)
  • The MariaDB forgejo database