apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "htwkalender.name" . }}-data-manager
  namespace: {{ .Release.Namespace }}
  labels:
    {{- include "htwkalender.labels" . | nindent 4 }}
    component: data-manager
  {{- with .Values.annotations }}
  annotations:
    {{- toYaml . | nindent 4 }}
  {{- end }}
spec:
  replicas: {{ .Values.dataManager.replicas }}
  selector:
    matchLabels:
      {{- include "htwkalender.selectorLabels" . | nindent 6 }}
  template:
    metadata:
      {{- with .Values.annotations }}
      annotations:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      labels:
        {{- include "htwkalender.labels" . | nindent 8 }}
        component: data-manager
    spec:
      securityContext:
        fsGroup: 1000
        runAsUser: 1000
        runAsGroup: 1000
      containers:
        - name: {{ .Chart.Name }}-data-manager
          image: "{{ .Values.dataManager.image.name }}"
          imagePullPolicy: {{ .Values.dataManager.image.pullPolicy }}
          ports:
            - name: data-manager
              containerPort: {{ .Values.dataManager.service.targetPort }}
              protocol: TCP
            - name: data-man-proto
              containerPort: {{ .Values.dataManager.service.protobufTargetPort }}
              protocol: TCP
          volumeMounts:
            {{- if .Values.persistence.enabled }}
            - name: {{ include "htwkalender.name" . }}-storage
              mountPath: /htwkalender-data-manager/data
            {{- end }}
      volumes:
        {{- if .Values.persistence.enabled }}
        - name: {{ include "htwkalender.name" . }}-storage
          persistentVolumeClaim:
            claimName: {{ include "htwkalender.name" . }}-storage
        {{- end }}
