apiVersion: apps/v1
kind: Deployment
metadata:
  name: prometheus
  namespace: monitoring-demo
  labels:
    app: prometheus
spec:
  replicas: 1
  selector:
    matchLabels:
      app: prometheus
  template:
    metadata:
      labels:
        app: prometheus
    spec:
      serviceAccountName: monitoring-demo
      containers:
        - name: prometheus
          image: prom/prometheus:v2.14.0
          args:
            - "--config.file=/etc/prometheus/prometheus.yml"
            - "--storage.tsdb.retention.time=20d"
          ports:
            - name: prometheus
              containerPort: 9090
          resources:
            requests:
              cpu: 10m
          livenessProbe:
            httpGet:
              path: /-/healthy
              port: 9090
          readinessProbe:
            httpGet:
              path: /-/ready
              port: 9090
          volumeMounts:
            - name: prometheus-data
              mountPath: /prometheus/
            - name: prometheus-config
              mountPath: /etc/prometheus/
      securityContext:
        runAsNonRoot: true
        runAsUser: 1000
        fsGroup: 2000
      volumes:
        - name: prometheus-data
          persistentVolumeClaim:
            claimName: prometheus-data
        - name: prometheus-config
          configMap:
            name: prometheus-config
            defaultMode: 420
        