apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: prometheus-deployment
  namespace: monitoring
spec:
  serviceName: prometheus
  replicas: 1
  selector:
    matchLabels:
      app: prometheus
  # strategy:
  #   rollingUpdate:
  #     maxSurge: 0
  #     maxUnavailable: 1
  #   type: RollingUpdate
  selector:
    matchLabels:
      app: prometheus
  template:
    metadata:
      name: prometheus
      labels:
        app: prometheus
    spec:
      securityContext:
        runAsUser: 1000
        runAsGroup: 3000
        fsGroup: 2000
      serviceAccount: prometheus
      containers:
      - name: prometheus
        image: prom/prometheus:v2.18.0
        args:
        - --web.enable-lifecycle
        - --storage.tsdb.no-lockfile 
        - --storage.tsdb.retention.time=6h
        - --config.file=/etc/prometheus/prometheus.yml
        # - '-alertmanager.url=http://alertmanager:9093'
        ports:
        - name: web
          containerPort: 9090
        volumeMounts:
        - name: config-volume
          mountPath: /etc/prometheus
        - name: alertrules-volume
          mountPath: /etc/prometheus-rules
        - name: prometheus-pv
          mountPath: /prometheus/data
      volumes:
      - name: config-volume
        configMap:
          name: prometheus-configmap
      - name: alertrules-volume
        configMap:
          name: prometheus-alertrules
      - name: prometheus-pv
        persistentVolumeClaim:
          claimName: cn-horiuchiysh-prometheus-pvc-prometheus-deployment-0
      nodeSelector:
        beta.kubernetes.io/os: linux
  volumeClaimTemplates:
    - metadata:
        name: cn-horiuchiysh-prometheus-pvc
      spec:
        storageClassName: manual
        selector:
          matchLabels:
            objective: prometheus
        accessModes:
          - ReadWriteOnce
        resources:
          requests:
            storage: 40Gi
