邮件通知

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 启用邮件通知

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

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

注意:stig-os-example 是一个示例配置文件名称。请使用集群中实际可用的配置文件名称。

为 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 适用于批量资源及其生成的报告。
  • 更多详情,请参见 使用 Scan 和 使用 ScanSuite。