邮件通知

Compliance Service 支持通过邮件发送扫描报告。

前提条件

  • global 集群中使用:需要将 Alauda Container Platform 升级到 v4.3.0 或更高版本。
  • 在业务集群中使用:需要安装 Alauda Container Platform Cluster Notification 插件。
  • 准备邮件服务器配置:

配置通知模板

创建一个 NotificationTemplate 资源以定义邮件内容:

apiVersion: ait.alauda.io/v1beta1
kind: NotificationTemplate
metadata:
  name: email-compliance-report-template
  namespace: cpaas-system
labels:
  cpaas.io/template.email.body.type: Html
  cpaas.io/template.language: EN
spec:
  templates:
    - type: Email
      subject: "Compliance {{ .labels.name }} Report"
      content: |-
        The compliance scan has completed. Please download the attached report ZIP file.

注意:

  • 资源名称不可自定义;Compliance 发送报告默认依赖此名称。
  • 通知模板需创建在 cpaas-system 命名空间下。

配置报告接收人

创建一个 ConfigMap 来指定邮件接收人:

apiVersion: v1
kind: ConfigMap
metadata:
  name: compliance-mail-recipients
  namespace: compliance-system
data:
  to: example1@alauda.io,example@gmail.com

注意:

  • 联系人资源必须创建在 compliance-system 命名空间下。
  • 资源名称必须与 reportDelivery.email.recipientsRef.name 的值保持一致。

启用扫描的邮件通知

Scan 资源的 spec 下直接添加 reportDelivery 部分:

apiVersion: compliance.security.alauda.io/v1alpha1
kind: Scan
metadata:
  name: os-scan
  namespace: compliance-system
spec:
  profile: stig-os-microos
  scanType: node
  reportDelivery:
    email:
      enabled: true
      recipientsRef:
        name: compliance-mail-recipients

启用 ScanSuite 的邮件通知

ScanSuite 资源的 spec 下直接添加 reportDelivery 部分:

apiVersion: compliance.security.alauda.io/v1alpha1
kind: ScanSuite
metadata:
  name: notify-scan-suite
  namespace: compliance-system
spec:
  profiles:
    - stig-k8s-api-server
  maxHistoricalResults: 3
  scanTemplate:
    scanType: node
    nodeScopeStrategy: auto
  reportDelivery:
    email:
      enabled: true
      recipientsRef:
        name: compliance-mail-recipients

资源特定说明

  • Scan 中,reportDelivery 仅适用于该单个 Scan 资源。
  • ScanSuite 中,reportDelivery 适用于批量资源及其生成的报告。
  • 更多详情请参见 Using ScanUsing ScanSuite