#apiVersion: v1
#kind: PersistentVolume
#metadata:
#  name: my-redis-pv
#spec:
#  capacity:
#    storage: 10Gi
#  accessModes:
#    - ReadWriteOnce
#  hostPath:
#    path: /data
#---
#apiVersion: v1
#kind: PersistentVolumeClaim
#metadata:
#  name: my-redis-pvc
#spec:
#  accessModes:
#    - ReadWriteOnce
#  resources:
#    requests:
#      storage: 10Gi
#---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: redis-stack-deployment
  namespace: bcx-opm
  labels:
    app: redis-stack
spec:
  replicas: 2
  selector:
    matchLabels:
      app: redis-stack
  template:
    metadata:
      labels:
        app: redis-stack
    spec:
      initContainers:
        - name: init-container
          image: busybox
          command: ["sh", "-c", "echo 'Running init script before pod start' && sleep 2"]
      containers:
        - name: redis-stack
          image: redis/redis-stack:latest
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 8001
              name: http-port
            - containerPort: 6379
              name: tcp-port
          volumeMounts:
            - name: redis-stack-volume
              mountPath: /data
      volumes:
        - name: redis-stack-volume
          hostPath:
            path: /data
---
apiVersion: v1
kind: Service
metadata:
  name: redis-stack-service
  namespace: bcx-opm
  labels:
    app: redis-stack
spec:
  type: ClusterIP
  ports:
    - port: 8001
      name: http-port
      targetPort: 8001
    - port: 16379
      name: tcp-port
      targetPort: 6379
  selector:
    app: redis-stack