apiVersion: apps/v1
kind: Deployment
metadata:
  name: prometheus-monitoring
  namespace: devops
  labels:
    app: prometheus-monitoring
  # NOTE: setting up the annotation so that this service will be discovered by Prometheus
  # for scraping. To make the service available,
  # set prometheus.io/scrape to true. Ensure that prometheus.io/port
  # is the targetPort defined in the service.
  annotations:
    prometheus.io/scrape: 'true'
    prometheus.io/port: '9090'
spec:
  replicas: 1
  selector:
    matchLabels:
      app: prometheus-monitoring
  template:
    metadata:
      labels:
        app: prometheus-monitoring
    spec:
      serviceAccountName: prometheus
      securityContext:
        fsGroup: 1000
      containers:
      - name: prometheus-monitoring
        securityContext:
          privileged: true
        image: prom/prometheus:v2.12.0
        #imagePullPolicy: Always
        command:
          - "/bin/sh"
          - "-c"
          - >
            set -x;
            /bin/prometheus --config.file=/etc/prometheus/config.yaml
        ports:
        - containerPort: 9090
          name: prometheus
          protocol: TCP
#        - containerPort: 3000
#          name: grafana
#          protocol: TCP
        volumeMounts:
        - name: prometheus-config-volume
          mountPath: /etc/prometheus/config.yaml
          subPath: config.yaml
        - name: prometheus-config-volume
          mountPath: /tmp/prometheus/rules
        - name: prometheus-config-volume
          mountPath: /tmp/prometheus/static-files
        - name: prometheus-storage-volume
          mountPath: /prometheus/
      volumes:
        - name: prometheus-config-volume
          configMap:
            name: prometheus-config
        # NOTE: This volume is ephemeral.
        # If you want this data to be persistent, then you will need to use a persistent volume
        - name: prometheus-storage-volume
          emptyDir: {}
         #
         # NOTE: update the right PV and PVC information
         #
#        volumeMounts:
#        - name: monitoring-efs-volume
#          mountPath: /mnt
#        - name: data-volume
#          mountPath: /prometheus/data
#      volumes:
#      - name: data-volume
#        persistentVolumeClaim:
#          claimName: prometheus-monitoring-ssd
#      - name: monitoring-efs-volume
#        persistentVolumeClaim:
#          claimName: monitoring-efs-pvc
