apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: redis-data
  labels:
    app: redis
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 10Gi
  storageClassName: standard
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: redis
  labels:
    app: redis
spec:
  selector:
    matchLabels:
      app: redis
  serviceName: redis
  template:
    metadata:
      labels:
        app: redis
    spec:
      containers:
        # This Redis definition is provided for convenience and pulls from Docker
        # Hub's public registry. For production use we recommend:
        #   - Vendoring this image to your own registry, or authenticating to Docker
        #     Hub to avoid pull rate limits.
        #   - Replacing this in-cluster instance with a managed service (e.g.
        #     ElastiCache, Azure Cache for Redis, Memorystore) or an official Redis
        #     installation source for durability and operational support.
        - image: docker.io/library/redis:7.4
          name: redis
          args:
            - --appendonly yes
          ports:
            - containerPort: 6379
          volumeMounts:
            - mountPath: "/data"
              name: "vol-data"
      volumes:
        - name: vol-data
          persistentVolumeClaim:
            claimName: redis-data
        - name: host-sys
          hostPath:
            path: /sys
      restartPolicy: Always
---
apiVersion: v1
kind: Service
metadata:
  name: redis
  labels:
    app: redis
spec:
  ports:
    - port: 6379
      targetPort: 6379
  selector:
    app: redis
