{{ include "common.storage.hostPathValidate" .Values }}
apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ template "netdata.name" . }}
  labels:
    app: {{ template "netdata.name" . }}
    chart: {{ template "netdata.chart" . }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
    role: parent
spec:
  replicas: 1
  strategy:
    type: Recreate
  selector:
    matchLabels: {{ include "common.labels.selectorLabels" . | nindent 6 }}
  template:
    metadata:
      labels: {{ include "common.labels.selectorLabels" . | nindent 8 }}
      annotations:
        rollme: {{ randAlphaNum 5 | quote }}
    spec:
      securityContext:
        fsGroup: 201
      serviceAccountName: {{ .Release.Name }}
      containers:
        - name: {{ .Chart.Name }}
          image: "{{ .Values.image.repository }}:{{ tpl .Values.image.tag . }}"
          imagePullPolicy: {{ .Values.image.pullPolicy }}
          {{ include "common.resources.limitation" . | nindent 10 }}
          env:
            {{ $envList := (default list .Values.environmentVariables) }}
            {{ include "common.containers.environmentVariables" (dict "environmentVariables" $envList) | nindent 12 }}
          ports:
            - name: http
              containerPort: 19999
              protocol: TCP
          livenessProbe:
            httpGet:
              path: /api/v1/info
              port: http
            initialDelaySeconds: 10
            periodSeconds: 10
            timeoutSeconds: 5
            failureThreshold: 5
            successThreshold: 1
          readinessProbe:
            httpGet:
              path: /api/v1/info
              port: http
            initialDelaySeconds: 10
            periodSeconds: 10
            timeoutSeconds: 5
            failureThreshold: 5
            successThreshold: 2
          startupProbe:
            httpGet:
              path: /api/v1/info
              port: http
            initialDelaySeconds: 10
            periodSeconds: 5
            timeoutSeconds: 2
            failureThreshold: 60
            successThreshold: 1
          volumeMounts: {{ include "common.storage.configureAppVolumeMountsInContainer" .Values | nindent 12 }}
            - name: os-release
              mountPath: /host/etc/os-release
              readOnly: true
            - name: sys
              mountPath: /host/sys
              readOnly: true
            - name: proc
              mountPath: /host/proc
              readOnly: true
            - name: user
              mountPath: /host/etc/passwd
              readOnly: true
            - name: group
              mountPath: /host/etc/group
              readOnly: true
          securityContext:
            capabilities:
              add:
                - SYS_PTRACE
      terminationGracePeriodSeconds: 60
      {{ include "common.networking.dnsConfiguration" .Values | nindent 6 }}
      volumes: {{ include "common.storage.configureAppVolumes" .Values | nindent 8 }}
        - name: os-release
          hostPath:
            path: /etc/os-release
        - name: proc
          hostPath:
            path: /proc
        - name: sys
          hostPath:
            path: /sys
        - name: user
          hostPath:
            path: /etc/passwd
        - name: group
          hostPath:
            path: /etc/group
