kind: PersistentVolume
apiVersion: v1
metadata:
  name: pv-alertmanager-0
  labels:
    type: local
spec:
  storageClassName: alert-manual
  capacity:
    storage: 5Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/data/pv-alertmanager-0"
---
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
  name: alertmanager
  labels:
    app: alertmanager
spec:
  serviceName: "alertmanager"
  replicas: 1
  selector:
    matchLabels:
      app: alertmanager
  template:
    metadata:
      labels:
        app: alertmanager
    spec:
      containers:
        - name: alertmanager
          image: "prom/alertmanager:v0.14.0"
          args:
            - --config.file=/etc/config/alertmanager.yml
            - --storage.path=/data
            - --web.external-url=/
          ports:
            - containerPort: 9093
              name: http
          readinessProbe:
            httpGet:
              path: "/#/status"
              port: 9093
            initialDelaySeconds: 30
            timeoutSeconds: 30
          volumeMounts:
            - name: config-volume
              mountPath: /etc/config
            - name: alertmanager
              mountPath: "/data"
              subPath: ""
          resources:
            limits:
              cpu: 200m
              memory: 200Mi
            requests:
              cpu: 200m
              memory: 200Mi
        - name: configmap-reload
          image: "jimmidyson/configmap-reload:v0.1"
          args:
            - --volume-dir=/etc/config
            - --webhook-url=http://localhost:9093/-/reload
          volumeMounts:
            - name: config-volume
              mountPath: /etc/config
              readOnly: true
          resources:
            limits:
              cpu: 10m
              memory: 10Mi
            requests:
              cpu: 10m
              memory: 10Mi
      volumes:
        - name: config-volume
          configMap:
            name: alertmanager
  volumeClaimTemplates:
  - metadata:
      labels:
        app: alertmanager
      name: alertmanager
    spec:
      storageClassName: alert-manual
      accessModes:
        - ReadWriteOnce
      resources:
        requests:
          storage: 2Gi
---
apiVersion: v1
kind: Service
metadata:
  name: alertmanager
spec:
  ports:
    - name: http
      port: 80
      protocol: TCP
      targetPort: 9093
  selector:
    app: alertmanager
  type: NodePort
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: alertmanager
data:
  alertmanager.yml: |
    global: null
    receivers:
    - name: default-receiver
    route:
      group_interval: 5m
      group_wait: 10s
      receiver: default-receiver
      repeat_interval: 3h