# Redis deployment for Kthena
# Deploy when using KV cache or other Redis-dependent features
# Usage (deploy in the same namespace as Kthena):
#   kubectl apply -f redis-standalone.yaml -n <namespace>

---
apiVersion: v1
kind: ConfigMap
metadata:
  name: redis-config
  labels:
    app.kubernetes.io/name: redis
    app.kubernetes.io/component: redis-config
data:
  REDIS_HOST: "redis-server"
  REDIS_PORT: "6379"

---
apiVersion: v1
kind: Secret
metadata:
  name: redis-secret
  labels:
    app.kubernetes.io/name: redis
    app.kubernetes.io/component: redis-secret
type: Opaque
data:
  REDIS_PASSWORD: ""

---
apiVersion: v1
kind: Service
metadata:
  name: redis-server
  labels:
    app.kubernetes.io/name: redis
    app.kubernetes.io/component: redis-server
spec:
  type: ClusterIP
  ports:
    - name: redis-port
      protocol: TCP
      port: 6379
      targetPort: 6379
  selector:
    app.kubernetes.io/name: redis
    app.kubernetes.io/component: redis-server

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: redis-server
  labels:
    app.kubernetes.io/name: redis
    app.kubernetes.io/component: redis-server
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: redis
      app.kubernetes.io/component: redis-server
  template:
    metadata:
      labels:
        app.kubernetes.io/name: redis
        app.kubernetes.io/component: redis-server
    spec:
      containers:
        - name: redis-server
          image: "redis:7.2-alpine"
          imagePullPolicy: IfNotPresent
          command:
            - redis-server
          ports:
            - name: redis-port
              containerPort: 6379
              protocol: TCP
          resources:
            limits:
              cpu: 2000m
              memory: 2Gi
            requests:
              cpu: 1000m
              memory: 1Gi
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
      restartPolicy: Always
      terminationGracePeriodSeconds: 30
      dnsPolicy: ClusterFirst
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 25%
      maxSurge: 25%
  revisionHistoryLimit: 10
  progressDeadlineSeconds: 600
