homek8s/apps/base/forgejo/deployment.yaml
Lance Walters b909456a3e fix(forgejo): allow anonymous public-repo browsing, block anon registry tokens at CF edge
REQUIRE_SIGNIN_VIEW was the F11 mitigation for ghost-user /v2/token grants,
but it also forced every public repo to a login page. Move the guard to a
Cloudflare custom rule that blocks /v2/token unless the request carries
Basic auth, and turn public browsing back on.
2026-12-01 22:27:47 -05:00

98 lines
3.4 KiB
YAML

apiVersion: apps/v1
kind: Deployment
metadata:
name: forgejo
namespace: forgejo
spec:
strategy:
type: Recreate
replicas: 1
selector:
matchLabels:
app: forgejo
template:
metadata:
labels:
app: forgejo
spec:
nodeSelector:
kubernetes.io/hostname: siriussec
containers:
- name: forgejo
image: codeberg.org/forgejo/forgejo:16
imagePullPolicy: IfNotPresent
ports:
- containerPort: 3000
name: http
env:
- name: FORGEJO__database__DB_TYPE
value: postgres
- name: FORGEJO__database__HOST
value: pg-rw:5432
- name: FORGEJO__database__NAME
value: forgejo
- name: FORGEJO__database__USER
valueFrom:
secretKeyRef:
name: forgejo-pg-app
key: username
- name: FORGEJO__database__PASSWD
valueFrom:
secretKeyRef:
name: forgejo-pg-app
key: password
- name: FORGEJO__server__ROOT_URL
value: https://forgejo.siriusdevops.com/
- name: FORGEJO__server__DOMAIN
value: forgejo.siriusdevops.com
- name: FORGEJO__server__SSH_DOMAIN
value: forgejo.siriusdevops.com
- name: FORGEJO__server__SSH_PORT
value: "222"
- name: FORGEJO__server__PROTOCOL
value: http
- name: FORGEJO__security__INSTALL_LOCK
value: "true"
- name: FORGEJO__packages__ENABLED
value: "true"
# Bot signup lockdown: admin-only account creation (web + API).
- name: FORGEJO__service__DISABLE_REGISTRATION
value: "true"
# Public-repo browsing is ON. Audit F11 had turned this on because
# Forgejo issues anonymous ("ghost user") registry tokens at
# /v2/token with Read on every package, so with public browsing
# every app image was world-pullable. That coupling is now cut at
# the edge instead: a Cloudflare zone custom rule ("Block anonymous
# Forgejo registry tokens") blocks /v2/token unless the request
# carries Basic auth, so anonymous pulls get 403 while containerd
# (which sends its `forgejo-pull` dockerconfigjson credentials)
# still pulls. Re-check that rule before turning this back to true.
- name: FORGEJO__service__REQUIRE_SIGNIN_VIEW
value: "false"
volumeMounts:
- name: data
mountPath: /data
# Custom site-root assets (robots.txt). GITEA_CUSTOM=/data/gitea,
# so Forgejo serves /data/gitea/public/robots.txt at /robots.txt.
- name: custom-public
mountPath: /data/gitea/public
readOnly: true
readinessProbe:
httpGet:
path: /
port: 3000
initialDelaySeconds: 20
periodSeconds: 10
resources:
requests:
cpu: 100m
memory: 256Mi
limits:
memory: 2Gi
volumes:
- name: data
persistentVolumeClaim:
claimName: forgejo-data
- name: custom-public
configMap:
name: forgejo-custom-public