# Redis 7 — backend de BullMQ (queues `relances`, `checkins`) et du cache.
# Single replica, suffisant V1. Persistance via local-path PVC pour ne pas
# perdre les jobs schedulés en cas de redémarrage du pod.
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: rubis-redis-data
  namespace: rubis
spec:
  accessModes: [ReadWriteOnce]
  storageClassName: local-path
  resources:
    requests:
      storage: 1Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: rubis-redis
  namespace: rubis
spec:
  replicas: 1
  strategy:
    type: Recreate # PVC RWO → pas de rollout simultané
  selector:
    matchLabels:
      app: rubis-redis
  template:
    metadata:
      labels:
        app: rubis-redis
    spec:
      containers:
        - name: redis
          image: redis:7.4-alpine
          args:
            - redis-server
            - --appendonly
            - 'yes'
            - --maxmemory
            - 256mb
            - --maxmemory-policy
            - allkeys-lru
          ports:
            - containerPort: 6379
              name: redis
          resources:
            requests:
              cpu: 50m
              memory: 64Mi
            limits:
              cpu: 500m
              memory: 384Mi
          volumeMounts:
            - name: data
              mountPath: /data
          livenessProbe:
            tcpSocket: { port: redis }
            initialDelaySeconds: 10
            periodSeconds: 15
          readinessProbe:
            exec:
              command: [redis-cli, ping]
            initialDelaySeconds: 5
            periodSeconds: 5
      volumes:
        - name: data
          persistentVolumeClaim:
            claimName: rubis-redis-data
---
apiVersion: v1
kind: Service
metadata:
  name: rubis-redis
  namespace: rubis
spec:
  type: ClusterIP
  selector:
    app: rubis-redis
  ports:
    - port: 6379
      targetPort: redis
      name: redis
