Files
2026-11-17 21:11:30 +00:00

39 lines
1.7 KiB
Markdown

# gitea-k3s-deployer
Lightweight Go deployment service that taps into Gitea (`https://git.site.latha.org`) and deploys applications to K3s (`dash.latha.org` / `k3s-kplae-u30796`) via Server-Side Apply.
## Features
- **Gitea Webhook Listener (`POST /webhook/gitea`)**: Verifies `X-Gitea-Signature` (HMAC-SHA256) and handles `ping`, `push`, `release`, and `workflow_run` events.
- **Two Deployment Modes**:
1. **`.latha-deploy.yaml` / `deploy.yaml`**: Declarative app spec that renders `Namespace`, `Deployment` (with safe non-`BestEffort` default `requests`/`limits`), `Service`, and Traefik `Ingress` (`websecure` + `letsencrypt`).
2. **`k8s/*.yaml` directory**: Syncs raw Kubernetes manifests with `${IMAGE_TAG}`, `${SHORT_SHA}`, `${COMMIT_SHA}`, `${APP_NAME}`, and `${REF}` substitution.
- **Web UI Dashboard (`GET /`)**: Shows registered apps, deployment history + logs, recent webhook deliveries, manual deploy trigger, and one-click rollback.
- **REST API & Observability**:
- `GET /healthz`, `GET /readyz`, `GET /metrics`
- `GET /api/apps`, `POST /api/apps`
- `GET /api/deployments`, `GET /api/deployments/{id}`, `POST /api/deploy`, `POST /api/deployments/{id}/rollback`
- `GET /api/webhooks`
## Example `.latha-deploy.yaml`
```yaml
name: my-app
namespace: apps
branch: main
image: git.site.latha.org/experiments/my-app
tagStrategy: sha # sha | latest | release | ref
port: 8080
host: my-app.site.latha.org
healthPath: /healthz
replicas: 1
secretRefs:
- my-app-secrets
```
## Secrets (OpenBao -> K8s Secret)
Create `gitea-deployer-secrets` in namespace `gitea-deployer` with:
- `GITEA_WEBHOOK_SECRET`: Shared HMAC-SHA256 secret configured on Gitea webhooks
- `GITEA_TOKEN`: Gitea personal access token for reading private repositories