Modelled on dynamic-qr: Traefik Gateway with Let's Encrypt, Longhorn PVC, 1 replica with Recreate, Calico network policies, and a rate limit on POST /api/leads. CI runs the tests in a Dockerfile stage before pushing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfmHGGiYUjNcvJoyzdf
125 lines
3.1 KiB
YAML
125 lines
3.1 KiB
YAML
# Served by Traefik through the Gateway API (GatewayClass `traefik`), the same way as dynamic-qr.
|
|
# Cloudflare connects to the origin over HTTPS: port 8443 is Traefik's `websecure` entry point
|
|
# (host port 443), 8000 its `web` entry point (host port 80), which only redirects to HTTPS.
|
|
#
|
|
# Let's Encrypt certificate via cert-manager (ClusterIssuer `lets-encrypt`, HTTP-01). The solver
|
|
# pod runs in this namespace and is allowed in by k8s/60-network-policy.yaml.
|
|
apiVersion: cert-manager.io/v1
|
|
kind: Certificate
|
|
metadata:
|
|
name: ins-landing-page-tls
|
|
namespace: ins-landing-page
|
|
spec:
|
|
secretName: ins-landing-page-tls
|
|
issuerRef:
|
|
group: cert-manager.io
|
|
kind: ClusterIssuer
|
|
name: lets-encrypt
|
|
dnsNames:
|
|
- ins-landing.containerverse.dev
|
|
usages:
|
|
- digital signature
|
|
- key encipherment
|
|
---
|
|
apiVersion: gateway.networking.k8s.io/v1
|
|
kind: Gateway
|
|
metadata:
|
|
name: ins-landing-page
|
|
namespace: ins-landing-page
|
|
spec:
|
|
gatewayClassName: traefik
|
|
listeners:
|
|
- name: http
|
|
protocol: HTTP
|
|
port: 8000
|
|
allowedRoutes:
|
|
namespaces:
|
|
from: Same
|
|
- name: websecure
|
|
protocol: HTTPS
|
|
port: 8443
|
|
hostname: ins-landing.containerverse.dev
|
|
tls:
|
|
mode: Terminate
|
|
certificateRefs:
|
|
- kind: Secret
|
|
group: ""
|
|
name: ins-landing-page-tls
|
|
allowedRoutes:
|
|
namespaces:
|
|
from: Same
|
|
---
|
|
# Plain HTTP: permanent redirect to HTTPS.
|
|
apiVersion: gateway.networking.k8s.io/v1
|
|
kind: HTTPRoute
|
|
metadata:
|
|
name: https-redirect
|
|
namespace: ins-landing-page
|
|
spec:
|
|
parentRefs:
|
|
- name: ins-landing-page
|
|
sectionName: http
|
|
hostnames:
|
|
- ins-landing.containerverse.dev
|
|
rules:
|
|
- matches:
|
|
- path:
|
|
type: PathPrefix
|
|
value: /
|
|
filters:
|
|
- type: RequestRedirect
|
|
requestRedirect:
|
|
scheme: https
|
|
port: 443
|
|
statusCode: 301
|
|
---
|
|
# The lead form is public; the honeypot only stops naive bots. Limit form posts per visitor so a
|
|
# script cannot fill the volume. depth: 1 takes the right-most X-Forwarded-For entry, which
|
|
# Cloudflare sets to the visitor (Traefik keeps that header only from Cloudflare's ranges).
|
|
apiVersion: traefik.io/v1alpha1
|
|
kind: Middleware
|
|
metadata:
|
|
name: lead-rate-limit
|
|
namespace: ins-landing-page
|
|
spec:
|
|
rateLimit:
|
|
average: 5
|
|
period: 1m
|
|
burst: 5
|
|
sourceCriterion:
|
|
ipStrategy:
|
|
depth: 1
|
|
---
|
|
apiVersion: gateway.networking.k8s.io/v1
|
|
kind: HTTPRoute
|
|
metadata:
|
|
name: ins-landing-page
|
|
namespace: ins-landing-page
|
|
spec:
|
|
parentRefs:
|
|
- name: ins-landing-page
|
|
sectionName: websecure
|
|
hostnames:
|
|
- ins-landing.containerverse.dev
|
|
rules:
|
|
- matches:
|
|
- path:
|
|
type: Exact
|
|
value: /api/leads
|
|
filters:
|
|
- type: ExtensionRef
|
|
extensionRef:
|
|
group: traefik.io
|
|
kind: Middleware
|
|
name: lead-rate-limit
|
|
backendRefs:
|
|
- name: ins-landing-page
|
|
port: 3000
|
|
- matches:
|
|
- path:
|
|
type: PathPrefix
|
|
value: /
|
|
backendRefs:
|
|
- name: ins-landing-page
|
|
port: 3000
|