apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  # Pay attention to the redis-role label at runtime. The self-determination logic in the image sets this value accordingly.
  name: {{ template "redis-ha.fullname" . }}-server
  labels:
    name: {{ template "redis-ha.fullname" . }}-server
    redis-node: "true"
{{ include "labels.standard" . | indent 4 }}
spec:
  replicas: {{ .Values.replicas.servers }}
  template:
    metadata:
      labels:
        app: {{ template "redis-ha.name" . }}
        release: {{ .Release.Name }}
        component: server
        name: {{ template "redis-ha.fullname" . }}-server
        redis-node: "true"
    spec:
      serviceAccountName: {{ template "redis-ha.serviceAccountName" . }}
      {{- if .Values.nodeSelector }}
      nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
      {{- end }}
      {{- if .Values.tolerations }}
      tolerations:
{{ toYaml .Values.tolerations | indent 8 }}
      {{- end }}
      affinity:
{{ tpl .Values.serverAffinity . | indent 8 }}
      containers:
      - name: redis
        image: {{ .Values.redis_image }}
        resources:
{{ toYaml .Values.resources.server | indent 10 }}
        env:
          - name: REDIS_SENTINEL_SERVICE_HOST
            value: "redis-sentinel"
          - name: REDIS_CHART_PREFIX
            value: {{ template "redis-ha.fullname" . }}-
{{- if .Values.auth }}
          - name: REDIS_PASS
            valueFrom:
              secretKeyRef:
                name: {{ template "redis-ha.fullname" . }}
                key: auth
{{- end }}
        ports:
          - containerPort: 6379
        volumeMounts:
          - mountPath: /redis-master-data
            name: data
      volumes:
      - name: data

