apiVersion: apps/v1
kind: Deployment
metadata:
  name: ghostfolio-redis
  namespace: ai
spec:
  replicas: 1
  selector:
    matchLabels:
      app: ghostfolio-redis
  template:
    metadata:
      labels:
        app: ghostfolio-redis
    spec:
      containers:
        - name: redis
          image: redis:7-alpine
          args:
            - "--requirepass"
            - "$(REDIS_PASSWORD)"
            - "--maxmemory"
            - "128mb"
            - "--maxmemory-policy"
            - "allkeys-lru"
          ports:
            - containerPort: 6379
          env:
            - name: REDIS_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: ghostfolio-secret
                  key: redis-password
          resources:
            requests:
              cpu: 50m
              memory: 64Mi
            limits:
              cpu: 250m
              memory: 192Mi
          readinessProbe:
            exec:
              command: ["sh", "-c", "redis-cli -a \"$REDIS_PASSWORD\" ping | grep -q PONG"]
            initialDelaySeconds: 5
            periodSeconds: 10
---
apiVersion: v1
kind: Service
metadata:
  name: ghostfolio-redis
  namespace: ai
spec:
  selector:
    app: ghostfolio-redis
  ports:
    - port: 6379
      targetPort: 6379
