chore: k8s manifests and Gitea CI for ins-landing.containerverse.dev

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
This commit is contained in:
ngqileandClaude Opus 5.5 committed 2026-12-01 11:24:33 +08:00
1 parent 0d50d3c09c
commit 91b6b31644
8 files changed
+590 -10

No files matched your search

+4
View File
@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: ins-landing-page
+95
View File
@@ -0,0 +1,95 @@
# Leads live in a SQLite file on this volume. ReadWriteOnce + 1 replica + Recreate: SQLite has a
# single writer, so two pods must never hold the file at once (not even during a rollout).
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ins-landing-page-data
namespace: ins-landing-page
spec:
storageClassName: longhorn
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
---
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
strategy:
type: Recreate
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
fsGroup: 1000 # so the app can write to the Longhorn volume
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: DB_PATH
value: /data/leads.db
ports:
- name: http
containerPort: 3000
volumeMounts:
- name: data
mountPath: /data
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"]
volumes:
- name: data
persistentVolumeClaim:
claimName: ins-landing-page-data
+124
View File
@@ -0,0 +1,124 @@
# 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
+61
View File
@@ -0,0 +1,61 @@
# 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
---
# 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