apiVersion: apps/v1
kind: Deployment
metadata:
  name: alertmanager
spec:
  replicas: 1
  selector:
    matchLabels:
      app: alertmanager
  template:
    metadata:
      name: alertmanager
      labels:
        app: alertmanager
    spec:
      containers:
        - name: alertmanager
          image: prom/alertmanager:latest
          args:
            - --config.file=/etc/alertmanager/config/alertmanager.yaml
            - --cluster.listen-address=[$(POD_IP)]:6783
            - --storage.path=/alertmanager
            - --data.retention=120h
            - --web.listen-address=:9093
            - --web.route-prefix=/
          ports:
            - name: web
              containerPort: 9093
              protocol: TCP
            - name: mesh
              containerPort: 6783
              protocol: TCP
          livenessProbe:
            failureThreshold: 10
            httpGet:
              path: /api/v1/status
              port: web
              scheme: HTTP
            periodSeconds: 10
            successThreshold: 1
            timeoutSeconds: 3
          readinessProbe:
            failureThreshold: 10
            httpGet:
              path: /api/v1/status
              port: web
              scheme: HTTP
            initialDelaySeconds: 3
            periodSeconds: 5
            successThreshold: 1
            timeoutSeconds: 3
          env:
            - name: POD_IP
              valueFrom:
                fieldRef:
                  apiVersion: v1
                  fieldPath: status.podIP
          volumeMounts:
            - name: config-volume
              mountPath: /etc/alertmanager/config
            - mountPath: /alertmanager
              name: alertmanager-main-db
      volumes:
        - name: config-volume
          configMap:
            defaultMode: 420
            name: alertmanager-config
        - name: alertmanager-main-db
          emptyDir: {}
