{{- if .Values.redis.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "consentos.fullname" . }}-redis
  labels:
    {{- include "consentos.labels" . | nindent 4 }}
    app.kubernetes.io/component: redis
spec:
  replicas: 1
  selector:
    matchLabels:
      {{- include "consentos.selectorLabels" (dict "Chart" .Chart "Release" .Release "component" "redis") | nindent 6 }}
  template:
    metadata:
      labels:
        {{- include "consentos.selectorLabels" (dict "Chart" .Chart "Release" .Release "component" "redis") | nindent 8 }}
    spec:
      containers:
        - name: redis
          image: "{{ .Values.redis.image.repository }}:{{ .Values.redis.image.tag }}"
          ports:
            - name: redis
              containerPort: 6379
              protocol: TCP
          livenessProbe:
            exec:
              command:
                - redis-cli
                - ping
            initialDelaySeconds: 10
            periodSeconds: 10
          readinessProbe:
            exec:
              command:
                - redis-cli
                - ping
            initialDelaySeconds: 5
            periodSeconds: 5
          resources:
            {{- toYaml .Values.redis.resources | nindent 12 }}
---
apiVersion: v1
kind: Service
metadata:
  name: {{ include "consentos.fullname" . }}-redis
  labels:
    {{- include "consentos.labels" . | nindent 4 }}
    app.kubernetes.io/component: redis
spec:
  type: ClusterIP
  ports:
    - port: 6379
      targetPort: redis
      protocol: TCP
      name: redis
  selector:
    {{- include "consentos.selectorLabels" (dict "Chart" .Chart "Release" .Release "component" "redis") | nindent 4 }}
{{- end }}
