homek8s/apps/base/osint/postgres-deployment.yaml
Sirius DevOps bc942e2571 registry(auth): require auth for image pulls (audit F11)
Forgejo 16 mints an anonymous ("ghost user") registry token on /v2/token and
grants it Read on every package regardless of repo visibility, so all 18 app
images were world-downloadable — including images of private repos
(siriusdevops-site, phs-site, sirius-growth-*, sgs-leadgen).

* FORGEJO__service__REQUIRE_SIGNIN_VIEW=true: /v2/token answers UNAUTHORIZED
  to anonymous clients, anonymous manifests get 401. This is the documented
  switch in routers/api/packages/container (Authenticate) and
  services/context/package.go (determineAccessMode). Side effect: the Forgejo
  web UI/API becomes login-only for anonymous visitors.
* imagePullSecrets: [forgejo-pull] on all 18 workloads that pull from the
  registry (osint, piedmont, sirius-growth, siriusdevops). The
  kubernetes.io/dockerconfigjson Secret is per-namespace and out of band
  (never in git); docs/registry-pull-auth.md documents why, how to recreate
  it, and the verification commands. No containerd-level credential.
2026-11-27 00:15:20 -05:00

102 lines
3.4 KiB
YAML

# TimescaleDB + PostGIS, single instance on local-path.
# NOT CloudNativePG: the app's alembic chain requires CREATE EXTENSION
# postgis AND timescaledb plus create_hypertable()/continuous aggregates, and
# this image (Dockerfile.pg, built amd64) is the exact Postgres the Pi stack
# ran. A CNPG cluster would need a custom CNPG-conformant Timescale image.
apiVersion: apps/v1
kind: Deployment
metadata:
name: osint-db
namespace: osint
labels:
app: osint-db
spec:
replicas: 1
# ReadWriteOnce PVC: old and new pod cannot both mount it.
strategy:
type: Recreate
selector:
matchLabels:
app: osint-db
template:
metadata:
labels:
app: osint-db
spec:
imagePullSecrets:
- name: forgejo-pull
tolerations:
- key: dedicated
operator: Exists
effect: PreferNoSchedule
# Local-path volume: the claim (osint-pgdata-linode) is pinned to linode by
# its PV, so the pod must be too. arch selector documents why: the image is
# amd64-only, as on every other node this can land on.
nodeSelector:
kubernetes.io/arch: amd64
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- linode
containers:
- name: postgres
image: forgejo.siriusdevops.com/sirius/osint-dashboard-pg:amd64-c48788d4b614-r3
imagePullPolicy: IfNotPresent
args:
- -c
- shared_preload_libraries=timescaledb
- -c
- shared_buffers=1GB
- -c
- max_connections=100
ports:
- containerPort: 5432
name: postgres
env:
- name: POSTGRES_USER
value: osint
- name: POSTGRES_DB
value: osint_data
# Bare `psql`/`pg_dump -U osint` inside this pod would otherwise
# default the database to the USER name and log
# `FATAL: database "osint" does not exist` (seen 2026-11-21 22:15
# on deploy/osint-db). PGDATABASE makes the correct db the default.
- name: PGDATABASE
value: osint_data
- name: PGDATA
value: /var/lib/postgresql/data/pgdata
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: osint-db
key: password
readinessProbe:
exec:
command: ["pg_isready", "-U", "osint", "-d", "osint_data", "-h", "127.0.0.1"]
initialDelaySeconds: 10
periodSeconds: 10
failureThreshold: 6
livenessProbe:
exec:
command: ["pg_isready", "-U", "osint", "-d", "osint_data", "-h", "127.0.0.1"]
initialDelaySeconds: 60
periodSeconds: 30
failureThreshold: 6
volumeMounts:
- name: pgdata
mountPath: /var/lib/postgresql/data
resources:
requests:
cpu: 200m
memory: 512Mi
limits:
memory: 2Gi
volumes:
- name: pgdata
persistentVolumeClaim:
claimName: osint-pgdata-linode