apiVersion: apps/v1
kind: Deployment
metadata:
  name: prometheus
  namespace: monitoring
  labels:
    app: prometheus
spec:
  replicas: 1
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
    type: RollingUpdate
  selector:
    matchLabels:
      app: prometheus
  template:
    metadata:
      labels:
        app: prometheus
      annotations:
        prometheus.io/scrape: "true"
        prometheus.io/port: "9090"
    spec:
      securityContext: 
        fsGroup: 1000
      containers:
      - name: prometheus
        image: private-repo:5000/prom/prometheus:v2.47.0
        args:
          - '--storage.tsdb.retention.time=6h'
          - '--storage.tsdb.path=/prometheus'
          - '--config.file=/etc/prometheus/prometheus.yml'
        ports:
        - name: web
          containerPort: 9090
        volumeMounts:
          - name: prometheus-config-volume
            mountPath: /etc/prometheus
          - name: pv-prometheus
            mountPath: /prometheus
      volumes: 
      - name: prometheus-config-volume
        configMap:
          defaultMode: 420
          name: prometheus-config  
      - name: pv-prometheus
        persistentVolumeClaim:
          claimName: pvc-prometheus
      initContainers:
        - name: init-chown
          image: private-repo:5000/busybox:1.28
          command: ["sh", "-c", "chown -R 1000:1000 /prometheus && chmod -R 775 /prometheus"]
          volumeMounts: 
          - mountPath: /prometheus   
            name: pv-prometheus
      nodeSelector:
        name: node-1
