apiVersion: v1
kind: Service
metadata:
  name: prometheus
  namespace: openfaas
  labels:
    app: prometheus
spec:
  type: NodePort
  ports:
    - port: 9090
      protocol: TCP
      targetPort: 9090
      nodePort: 31119
  selector:
    app: prometheus
---
apiVersion: apps/v1beta1 # for versions before 1.6.0 use extensions/v1beta1
kind: Deployment
metadata:
  name: prometheus
  namespace: openfaas
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: prometheus
    spec:
      containers:
      - name: prometheus
        image: alexellis2/prometheus-arm64:1.5.2
        command: ["prometheus","-config.file=/etc/prometheus/prometheus.yml", "-storage.local.path=/prometheus", "-storage.local.memory-chunks=10000", "--alertmanager.url=http://alertmanager.openfaas:9093"]
        imagePullPolicy: Always
        ports:
        - containerPort: 9090
          protocol: TCP
        resources:
          requests:
            memory: 512Mi
          limits:
            memory: 512Mi
        volumeMounts:
        - mountPath: /etc/prometheus/prometheus.yml
          name: prometheus-config
          subPath: prometheus.yml
        - mountPath: /etc/prometheus/alert.rules
          name: prometheus-config
          subPath: alert.rules
      volumes:
        - name: prometheus-config
          configMap:
            name: prometheus-config
            items:
              - key: prometheus.yml
                path: prometheus.yml
                mode: 0644
              - key: alert.rules
                path: alert.rules
                mode: 0644
