Files
ins-landing-page/k8s/40-app.yaml
T
ngqileandClaude Opus 5.5 f78bd635a2 feat: store leads in PostgreSQL instead of SQLite
- server.js uses pg (pinned 8.23.1), reads DATABASE_URL, creates the
  leads table on start, fails fast if Postgres is unreachable
- tests run against a real Postgres in a throwaway schema
- CI runs the test image against a throwaway Postgres on DinD
- k8s: Postgres 18 StatefulSet (Longhorn, 2Gi), init container wait,
  password secret, network policy app-to-postgres; app no longer needs
  a volume or Recreate
- README: DBeaver via port-forward, CSV export via docs/export-leads.sql

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfmHGGiYUjNcvJoyzdf
2026-12-01 11:55:14 +08:00

93 lines
2.6 KiB
YAML

apiVersion: v1
kind: Service
metadata:
name: ins-landing-page
namespace: ins-landing-page
spec:
selector:
app: ins-landing-page
ports:
- name: http
port: 3000
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: ins-landing-page
namespace: ins-landing-page
spec:
replicas: 1
selector:
matchLabels:
app: ins-landing-page
template:
metadata:
labels:
app: ins-landing-page
spec:
imagePullSecrets:
- name: regcred
terminationGracePeriodSeconds: 10
securityContext:
runAsNonRoot: true
runAsUser: 1000 # the image's `node` user
runAsGroup: 1000
# Start the app only once Postgres answers, instead of crash-looping into a growing back-off
# after a first install or a node restart. Same image as the StatefulSet, so nothing extra is pulled.
initContainers:
- name: wait-for-postgres
image: postgres:18
command: ["sh", "-c", "until pg_isready -h postgres -p 5432 -U ins -d ins; do sleep 2; done"]
resources:
requests:
cpu: 10m
memory: 16Mi
limits:
memory: 64Mi
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop: ["ALL"]
containers:
- name: ins-landing-page
# One moving tag per profile (CI); the rollout restarts the pod to pull it.
image: gitea.containerverse.dev/solvway/ins-landing-page:ins-landing-page-prd-latest
imagePullPolicy: Always
env:
- name: PORT
value: "3000"
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: ins-landing-page-db
key: POSTGRES_PASSWORD
- name: DATABASE_URL
value: postgres://ins:$(POSTGRES_PASSWORD)@postgres:5432/ins
ports:
- name: http
containerPort: 3000
readinessProbe:
httpGet:
path: /
port: http
periodSeconds: 10
livenessProbe:
httpGet:
path: /
port: http
initialDelaySeconds: 10
periodSeconds: 30
failureThreshold: 3
resources:
requests:
cpu: 20m
memory: 48Mi
limits:
memory: 192Mi
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop: ["ALL"]