apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "chart.resourceNamePrefix" . }}trivy
  labels:
    app.kubernetes.io/component: trivy
    {{- include "chart.labels" . | nindent 4 }}
spec:
  replicas: 1
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app.kubernetes.io/component: trivy
      {{- include "chart.selectorLabels" . | nindent 6 }}
  template:
    metadata:
      labels:
        app.kubernetes.io/component: trivy
        {{- include "chart.selectorLabels" . | nindent 8 }}
    spec:
      containers:
        - name: trivy
          image: {{ .Values.trivy.deploy.image }}
          command: ['trivy', '--debug', '--cache-dir', '/trivy', 'server', '--listen', '0.0.0.0:8081']
          volumeMounts:
          - name: trivy
            mountPath: "/trivy"
          ports:
          - name: http
            containerPort: 8081
            protocol: TCP
          resources:
            {{- toYaml .Values.trivy.deploy.resources | nindent 12 }}
      volumes:
      - name: trivy
      {{- if .Values.trivy.persistence.enabled }}
        persistentVolumeClaim:
          claimName: {{ include "chart.resourceNamePrefix" . }}trivy
      {{- else }}
        emptyDir: {}
      {{- end -}}
