| .. | ||
| configmap-app.yaml | ||
| configmap.yaml | ||
| deployment.yaml | ||
| ingress-tailscale-fixed.yaml | ||
| ingress-tailscale.yaml | ||
| ingress.yaml | ||
| kustomization.yaml | ||
| namespace.yaml | ||
| pv-rbd.yaml | ||
| pv.yaml | ||
| pvc-rbd.yaml | ||
| pvc.yaml | ||
| README.md | ||
| secret.yaml | ||
| service-tailscale-https.yaml | ||
| service-tailscale.yaml | ||
| service.yaml | ||
| setup-database-auto.sh | ||
| setup-database.sh | ||
Forgejo Deployment on Home K3s Cluster
This deploys Forgejo (Git server) on the home k3s cluster using the existing MariaDB instance.
Prerequisites
- MariaDB is already running in the
datanamespace - Longhorn storage class is available
- 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 MariaDBsecret-key: Generate a random 64-character stringinternal-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:
- The initial setup page should show
- Database settings should be pre-filled
- Create your admin account
- 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