apiVersion: apps/v1
kind: Deployment
metadata:
  name: redis-deploy
  namespace: voting-app-stack
  labels:
    name:  redis-deploy
spec:
  replicas: 1
  
  selector:
    matchLabels:
      name: redis-pod
      type: redis-db

  template:
    metadata:
      labels:
        name: redis-pod
        type: redis-db
    spec:
      containers:
      - name: redis
        image: redis
        args: ["--requirepass", "password"]
        resources:
          limits:
            memory: "128Mi"
            cpu: "100m"
        ports:
        - containerPort: 6379
        livenessProbe:
          exec:
            command:
            - /bin/sh
            - -c
            - exec redis-cli ping
          failureThreshold: 6
          initialDelaySeconds: 30
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 5
        readinessProbe:
          exec:
            command:
            - /bin/sh
            - -c
            - exec redis-cli ping
          failureThreshold: 6
          initialDelaySeconds: 30
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 5
        volumeMounts:
        - mountPath: /var/lib/redis/data
          name: redis-pv-claim
      volumes:
      - name: redis-pv-claim
        persistentVolumeClaim:
          claimName: redis-pv-claim
