---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  labels:
    app: alertmanager
  name: alertmanager
  namespace: cloud-paas
spec:
  serviceName: alertmanager
  podManagementPolicy: Parallel
  replicas: 1
  updateStrategy:
    type: RollingUpdate
    rollingUpdate:
      partition: 0
  selector:
    matchLabels:
      app: alertmanager
  template:
    metadata:
      labels:
        app: alertmanager
      annotations:
        "consul.hashicorp.com/connect-inject": "false"
    spec:
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            - labelSelector:
                matchLabels:
                  app: alertmanager
              topologyKey: kubernetes.io/hostname
#          # 单节点用这个
#          preferredDuringSchedulingIgnoredDuringExecution:
#            - weight: 100
#              podAffinityTerm:
#                topologyKey: kubernetes.io/hostname
      terminationGracePeriodSeconds: 10
      securityContext:
        fsGroup: 1000
      volumes:
        - name: alert-volume
          configMap:
            name: alertmanager
      containers:
        - args:
            - --config.file=/etc/alertmanager/config.yml
            - --storage.path=/etc/alertmanager
          image: prom/alertmanager:v0.16.2
          name: alertmanager
          ports:
            - containerPort: 9093
              name: alertmanager
              protocol: TCP
          resources:
            limits:
              cpu: 100m
              memory: 64Mi
            requests:
              cpu: 10m
              memory: 32Mi
          volumeMounts:
            - mountPath: /etc/alertmanager
              name: alert-volume
