1.qq邮箱开启SMTP服务(163同理)
1.1 设置 -> 账户 -> POP3/IMAP/SMTP/Exchange/CardDAV/CalDAV服务->开启POP3/SMTP
1.2 发送短信后将会收到密码,填入smtp_auth_password

2.app部署并集成开源邮件系统

apiVersion: v1
kind: ConfigMap
metadata:
  name: alertmanager-config
  labels:
    monitor: alertmanager
  namespace: kube-system
data:
  alertmanager.yml: |
    global:
      resolve_timeout: 5m
      smtp_from: '*********@qq.com'
      smtp_smarthost: 'smtp.qq.com:465'
      smtp_auth_username: '*********@qq.com'
      smtp_auth_password: '***************'
      smtp_require_tls: false
      smtp_hello: 'qq.com'
      
    route:
      group_by: ['alertname']
      group_wait: 5s
      group_interval: 5s
      repeat_interval: 5m
      receiver: 'email'
    receivers:
    - name: 'email'
      email_configs:
      - to: '*********@qq.com'
        send_resolved: true
    inhibit_rules:
      - source_match:
          severity: 'critical'
        target_match:
          severity: 'warning'
        equal: ['alertname', 'dev', 'instance']
---
apiVersion: v1
kind: ReplicationController
metadata:
  labels:
    monitor: alertmanager
  name: alertmanager
  namespace: kube-system
spec:
  replicas: 1
  template:
    metadata:
      name: alertmanager
      labels:
        monitor: alertmanager
    spec:
      containers:
      - image: prom/alertmanager:v0.15.2
        name: alertmanager
        args:
        - "--config.file=/etc/alertmanager/alertmanager.yml"
        - "--storage.path=/alertmanager"
        ports:
        - containerPort: 9093
          protocol: TCP
        volumeMounts:
        - name: data
          mountPath: "/alertmanager"
        - name: config-volume
          mountPath: "/etc/alertmanager/alertmanager.yml"
          subPath: alertmanager.yml
        # - name: config-volume
        #   mountPath: "/etc/prometheus/rules/hoststats.rules"
        #   subPath: hoststats.rules
        resources:
          requests:
            cpu: 100m
            memory: 100Mi
          limits:
            cpu: 500m
            memory: 500Mi
      serviceAccountName: prometheus    
      volumes:
      - name: data
        emptyDir: {}
      - name: config-volume
        configMap:
          name: alertmanager-config
---
kind: Service
apiVersion: v1
metadata:
  labels:
    monitor: alertmanager
  name: alertmanager
  namespace: kube-system
spec:
  type: NodePort
  ports:
  - port: 9093
    protocol: TCP
    targetPort: 9093
    nodePort: 39093
  selector:
    monitor: alertmanager

完毕
在这里插入图片描述

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐