---
apiVersion: v1
kind: Deployment
metadata:
  name: "{{ meta.name }}-redis"
  namespace: "{{ project_name }}"
  labels:
    app.kubernetes.io/name: 'redis'
    app.kubernetes.io/instance: 'redis-{{ meta.name }}'
    app.kubernetes.io/component: cache
    app.kubernetes.io/part-of: '{{ deployment_type }}'
    app.kubernetes.io/managed-by: '{{ deployment_type }}-operator'
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: 'redis'
      app.kubernetes.io/instance: 'redis-{{ meta.name }}'
      app.kubernetes.io/component: cache
      app.kubernetes.io/part-of: '{{ deployment_type }}'
      app.kubernetes.io/managed-by: '{{ deployment_type }}-operator'
  template:
    metadata:
      labels:
        app.kubernetes.io/name: 'redis'
        app.kubernetes.io/instance: 'redis-{{ meta.name }}'
        app.kubernetes.io/component: cache
        app.kubernetes.io/part-of: '{{ deployment_type }}'
        app.kubernetes.io/managed-by: '{{ deployment_type }}-operator'
    spec:
{% if image_pull_secret %}
      imagePullSecrets:
        - name: {{ image_pull_secret }}
{% endif %}
{% if affinity is defined and affinity.node_affinity is defined %}
      affinity:
        nodeAffinity: {{ affinity.node_affinity }}
{% endif %}
      containers:
        - name: redis
          image: "{{ redis_image }}"
          imagePullPolicy: "IfNotPresent"
          volumeMounts:
            - readOnly: false
              mountPath: /data
              name: '{{ meta.name }}-redis-data'
          ports:
            - protocol: TCP
              containerPort: 6379
{% if redis_resource_requirements is defined %}
          resources: {{ redis_resource_requirements }}
{% endif %}
      volumes:
        - name: '{{ meta.name }}-redis-data'
          persistentVolumeClaim:
            claimName: '{{ meta.name }}-redis-data'
