1# ============================================================================= 2# AI Software Factory — Redis 7 (Deployment + Service) 3# 4# Used for caching, BullMQ job queues and realtime presence/pubsub. 5# Single replica for simplicity. For production, prefer MANAGED ElastiCache / 6# Memorystore / AOF-backed replicas — a lost Redis queue means lost jobs. 7# 8# PVC NOTE: 9# Redis persistence (AOF) is enabled below with a ReadWriteOnce PVC. 10# If you switch to managed Redis, delete the volume + volumeMount entirely 11# and point REDIS_URL at the managed endpoint via the factory-config 12# ConfigMap / factory-secrets Secret. 13# ============================================================================= 14apiVersion: apps/v1 15kind: Deployment 16metadata: 17 name: redis 18 labels: 19 app.kubernetes.io/name: redis 20 app.kubernetes.io/component: cache 21spec: 22 replicas: 1 23 selector: 24 matchLabels: 25 app.kubernetes.io/name: redis 26 strategy: 27 type: Recreate # single-replica with a RWO PVC 28 template: 29 metadata: 30 labels: 31 app.kubernetes.io/name: redis 32 app.kubernetes.io/component: cache 33 spec: 34 containers: 35 - name: redis 36 image: redis:7-alpine 37 args: 38 - redis-server 39 - --appendonly 40 - "yes" 41 - --appendfsync 42 - everysec 43 - --maxmemory 44 - 1gb 45 - --maxmemory-policy 46 - allkeys-lru 47 # If you enable a password, create a factory-db style secret with 48 # REDIS_PASSWORD and add: 49 # - --requirepass "$(REDIS_PASSWORD)" 50 # and pass REDIS_PASSWORD via envFrom secretRef. 51 ports: 52 - containerPort: 6379 53 name: redis 54 resources: 55 requests: 56 cpu: 250m 57 memory: 256Mi 58 limits: 59 cpu: "1" 60 memory: 1Gi 61 volumeMounts: 62 - name: redisdata 63 mountPath: /data 64 readinessProbe: 65 tcpSocket: 66 port: 6379 67 periodSeconds: 5 68 livenessProbe: 69 tcpSocket: 70 port: 6379 71 periodSeconds: 15 72 volumes: 73 - name: redisdata 74 persistentVolumeClaim: 75 # PVC `factory-redis` must exist (20Gi example). See README: 76 # kubectl apply -f - <<EOF 77 # apiVersion: v1 78 # kind: PersistentVolumeClaim 79 # metadata: 80 # name: factory-redis 81 # spec: 82 # accessModes: [ReadWriteOnce] 83 # resources: 84 # requests: 85 # storage: 5Gi 86 # EOF 87 claimName: factory-redis 88--- 89apiVersion: v1 90kind: Service 91metadata: 92 name: factory-redis 93 labels: 94 app.kubernetes.io/name: redis 95spec: 96 type: ClusterIP 97 selector: 98 app.kubernetes.io/name: redis 99 ports: 100 - name: redis 101 port: 6379 102 targetPort: 6379 103