Files
ins-landing-page/k8s/60-network-policy.yaml
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

83 lines
2.0 KiB
YAML

# Ingress rules for namespace ins-landing-page (enforced by Calico). Everything is denied unless
# a policy below allows it. The kubelet's probes come from the pod's own node, which Calico always
# allows, so they need no rule.
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: default-deny-ingress
namespace: ins-landing-page
spec:
podSelector: {}
policyTypes:
- Ingress
---
# Traefik (MicroK8s ingress addon, namespace `ingress`) to the app.
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: app-from-traefik
namespace: ins-landing-page
spec:
podSelector:
matchLabels:
app: ins-landing-page
policyTypes:
- Ingress
ingress:
- from:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: ingress
podSelector:
matchLabels:
app.kubernetes.io/name: traefik
ports:
- protocol: TCP
port: 3000
---
# Postgres: app pods only (kubectl exec and port-forward are not pod network traffic and are unaffected).
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: postgres-from-app
namespace: ins-landing-page
spec:
podSelector:
matchLabels:
app: postgres
policyTypes:
- Ingress
ingress:
- from:
- podSelector:
matchLabels:
app: ins-landing-page
ports:
- protocol: TCP
port: 5432
---
# cert-manager's HTTP-01 solver pod: Traefik must reach it, or the certificate cannot be issued
# or renewed.
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: acme-solver-from-traefik
namespace: ins-landing-page
spec:
podSelector:
matchLabels:
acme.cert-manager.io/http01-solver: "true"
policyTypes:
- Ingress
ingress:
- from:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: ingress
podSelector:
matchLabels:
app.kubernetes.io/name: traefik
ports:
- protocol: TCP
port: 8089