# Rubis Landing — Astro 6 SSR (Node 22).
# Sert rubis.pro/* (pages statiques prerenderées) + rubis.pro/blog/* (SSR
# qui fetch apps/api JSON via le DNS K3s rubis-api.rubis.svc.cluster.local).
#
# Routing Traefik : Host(`rubis.pro`) → service rubis-landing:4321
# (les pages légales et le blog sont des routes Astro internes).
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: rubis-landing
  namespace: rubis
spec:
  replicas: 1
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
  selector:
    matchLabels:
      app: rubis-landing
  template:
    metadata:
      labels:
        app: rubis-landing
    spec:
      imagePullSecrets:
        - name: gitea-registry
      containers:
        - name: landing
          image: git.arthurbarre.fr/ordinarthur/rubis-landing:latest
          imagePullPolicy: Always
          ports:
            - containerPort: 4321
              name: http
          envFrom:
            - configMapRef: { name: rubis-landing-config }
          resources:
            requests:
              cpu: 50m
              memory: 128Mi
            limits:
              cpu: 500m
              memory: 384Mi
          startupProbe:
            httpGet: { path: /, port: http }
            initialDelaySeconds: 5
            periodSeconds: 5
            failureThreshold: 30
          livenessProbe:
            httpGet: { path: /, port: http }
            periodSeconds: 30
            timeoutSeconds: 5
            failureThreshold: 3
          readinessProbe:
            httpGet: { path: /, port: http }
            periodSeconds: 10
            timeoutSeconds: 3
            failureThreshold: 3
---
# NodePort — Traefik (sur la VM Proxmox) tape sur 10.10.10.5:30111.
# Le routing dynamique Traefik vit dans le repo proxmox :
#   ansible/roles/traefik/templates/rubis.yml.j2
apiVersion: v1
kind: Service
metadata:
  name: rubis-landing
  namespace: rubis
spec:
  type: NodePort
  selector:
    app: rubis-landing
  ports:
    - port: 4321
      targetPort: http
      nodePort: 30111
      name: http
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: rubis-landing-config
  namespace: rubis
data:
  TZ: 'Europe/Paris'
  HOST: '0.0.0.0'
  PORT: '4321'
  NODE_ENV: 'production'
  LOG_LEVEL: 'info'
  # URL interne pour fetcher l'API JSON depuis le SSR Astro. Pas besoin de
  # passer par l'extérieur (app.rubis.pro) — DNS K3s suffit.
  API_URL: 'http://rubis-api.rubis.svc.cluster.local:3333'
