# 📦 Fusero VPS Deployment Guide

This guide walks you through deploying the Fusero full-stack app to a plain Ubuntu VPS using Kubernetes (k3s), Helm, and automatic HTTPS via cert-manager.

---

## 📋 Prerequisites

- ✅ Ubuntu 22.04 VPS with root or sudo access  
- ✅ Domain names pointed to your VPS IP:  
  - api.fusero.nl → for the backend  
  - app.fusero.nl → for the frontend  
- ✅ Git access to your repo

---

## ☸️ 1. Install Kubernetes (k3s)

curl -sfL https://get.k3s.io | sh -

Set kubeconfig so kubectl works:  
echo 'export KUBECONFIG=/etc/rancher/k3s/k3s.yaml' >> ~/.bashrc  
source ~/.bashrc

Verify:  
kubectl get nodes

---

## 📦 2. Install Helm

curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash

Verify:  
helm version

---

## 📁 3. Clone the Project

git clone https://your.gitea.repo/fusero-app-boilerplate.git  
cd fusero-app-boilerplate

---

## 🔐 4. Set Up HTTPS (cert-manager)

Install cert-manager:  
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.14.3/cert-manager.yaml

Check pods:  
kubectl get pods -n cert-manager

Create file cluster-issuer.yaml with this content:

apiVersion: cert-manager.io/v1  
kind: ClusterIssuer  
metadata:  
  name: letsencrypt-prod  
spec:  
  acme:  
    server: https://acme-v02.api.letsencrypt.org/directory  
    email: your@email.com  
    privateKeySecretRef:  
      name: letsencrypt-prod  
    solvers:  
      - http01:  
          ingress:  
            class: nginx

Apply it:  
kubectl apply -f cluster-issuer.yaml

---

## 🌍 5. Update DNS

Ensure both api.fusero.nl and app.fusero.nl point to your VPS IP address.

Check propagation:  
ping api.fusero.nl

---

## 🚀 6. Deploy with Helm

Ensure you're in the repo root and the chart directory exists.

helm upgrade --install fusero ./chart -f chart/values-prod.yaml

This deploys frontend, backend, Postgres, ingress, and HTTPS.

---

## 📜 7. Verify Access

Frontend: https://app.fusero.nl  
Backend API: https://api.fusero.nl

---

## 🔁 8. (Optional) Rerun DB Migrations

kubectl delete job fusero-backend-db-init  
helm upgrade fusero ./chart -f chart/values-prod.yaml

---

## 🧪 9. Useful Commands

View backend logs:  
kubectl logs deployment/fusero-backend

View frontend logs:  
kubectl logs deployment/fusero-frontend

View pods and services:  
kubectl get pods,svc,deployments

---

## ✅ You’re Done!

You now have a production deployment of Fusero on a raw VPS with:  
- Kubernetes (via k3s)  
- TLS via Let's Encrypt  
- Helm-managed services  
- DNS routing for subdomains

For CI/CD automation via Gitea, see `.gitea-ci.yml` in the repo root.
