×

功耗监控功能目前仅为技术预览版。技术预览版功能不受 Red Hat 生产服务级别协议 (SLA) 的支持,可能功能不完整。Red Hat 不建议在生产环境中使用这些功能。这些功能可让客户提前访问即将推出的产品功能,从而能够在开发过程中测试功能并提供反馈。

有关 Red Hat 技术预览版功能的支持范围的更多信息,请参见 技术预览版功能支持范围

Kepler 资源是 Kubernetes 自定义资源定义 (CRD),它使您可以配置 Kepler 资源的部署并监控其状态。

Kepler 配置

您可以使用 Kepler 资源的 spec 字段配置 Kepler。

确保您的 Kepler 实例名称为 kepler。功耗监控操作符 Webhook 将拒绝所有其他实例。

以下是配置选项列表:

表 1. Kepler 配置选项
名称 规范 描述 默认值

端口

exporter.deployment

节点上公开 Prometheus 指标的端口。

9103

nodeSelector

exporter.deployment

Kepler exporter Pod 调度的节点。

kubernetes.io/os: linux

tolerations

exporter.deployment

Kepler exporter 的容忍度,允许 Pod 调度到具有特定特征的节点上。

- operator: "Exists"

具有默认配置的 Kepler 资源示例
apiVersion: kepler.system.sustainable.computing.io/v1alpha1
kind: Kepler
metadata:
  name: kepler
spec:
  exporter:
    deployment:
      port: 9103 (1)
      nodeSelector:
        kubernetes.io/os: linux (2)
      Tolerations: (3)
      - key: ""
        operator: "Exists"
        value: ""
        effect: ""
1 Prometheus 指标在 9103 端口上公开。
2 Kepler Pod 调度到 Linux 节点上。
3 默认容忍度允许 Kepler 调度到任何节点。

监控 Kepler 状态

您可以使用 Kepler 资源的 status 字段监控 Kepler exporter 的状态。

status.exporter 字段包含以下信息:

  • 当前运行 Kepler Pod 的节点数

  • 应该运行 Kepler Pod 的节点数

  • 表示 Kepler 资源健康状况的条件

这为您提供了对通过 spec 字段所做更改的宝贵见解。

Kepler 资源状态示例
apiVersion: kepler.system.sustainable.computing.io/v1alpha1
kind: Kepler
metadata:
  name: kepler
status:
 exporter:
   conditions: (1)
     - lastTransitionTime: '2024-01-11T11:07:39Z'
       message: Reconcile succeeded
       observedGeneration: 1
       reason: ReconcileSuccess
       status: 'True'
       type: Reconciled
     - lastTransitionTime: '2024-01-11T11:07:39Z'
       message: >-
         Kepler daemonset "kepler-operator/kepler" is deployed to all nodes and
         available; ready 2/2
       observedGeneration: 1
       reason: DaemonSetReady
       status: 'True'
       type: Available
   currentNumberScheduled: 2 (2)
   desiredNumberScheduled: 2 (3)
1 Kepler 资源的健康状况。在此示例中,Kepler 已成功协调并准备就绪。
2 当前运行 Kepler Pod 的节点数为 2。
3 想要运行 Kepler Pod 的节点数为 2。

配置 Kepler 以使用 Redfish

您可以将 Kepler 配置为使用 Redfish 作为运行或托管容器的来源。然后,Kepler 可以监控这些容器的功耗。

先决条件
  • 您可以访问 OpenShift Container Platform Web 控制台。

  • 您已以具有 cluster-admin 角色的用户身份登录。

  • 您已安装功耗监控操作符。

步骤
  1. 在 Web 控制台的**管理员**视角中,单击**操作符** → **已安装的操作符**。

  2. 从**已安装的操作符**列表中单击**Red Hat OpenShift 的功耗监控**,然后单击**Kepler** 选项卡。

  3. 单击**创建 Kepler**。如果您已创建 Kepler 实例,请单击**编辑 Kepler**。

  4. 通过指定必需的 secretRef 字段来配置 Kepler 实例的 .spec.exporter.redfish。您还可以配置可选的 probeIntervalskipSSLVerify 字段以满足您的需求。

    Kepler 实例示例
    apiVersion: kepler.system.sustainable.computing.io/v1alpha1
    kind: Kepler
    metadata:
      name: kepler
    spec:
      exporter:
        deployment:
    # ...
        redfish:
          secretRef: <secret_name> required (1)
          probeInterval: 60s (2)
          skipSSLVerify: false (3)
    # ...
    1 必需:指定包含访问 Redfish 服务器凭据的密钥的名称。
    2 可选:控制从 Redfish 查询功耗信息的频率。默认值为 60s
    3 可选:控制 Kepler 是否跳过验证 Redfish 服务器证书。默认值为 false

    部署 Kepler 后,将创建 openshift-power-monitoring 命名空间。

  5. 创建具有以下数据格式的 redfish.csv 文件:

    <your_kubelet_node_name>,<redfish_username>,<redfish_password>,https://<redfish_ip_or_hostname>/
    redfish.csv 文件示例
    control-plane,exampleuser,examplepass,https://redfish.nodes.example.com
    worker-1,exampleuser,examplepass,https://redfish.nodes.example.com
    worker-2,exampleuser,examplepass,https://another.redfish.nodes.example.com
  6. openshift-power-monitoring 命名空间下创建密钥。您必须在以下条件下创建密钥:

    • 密钥类型为 Opaque

    • 凭据存储在密钥的 data 字段中的 redfish.csv 密钥下。

    $ oc -n openshift-power-monitoring \
          create secret generic redfish-secret \
          --from-file=redfish.csv
    示例输出
    apiVersion: v1
    kind: Secret
    metadata:
      name: redfish-secret
    data:
      redfish.csv: YmFyCg==
      # ...

    在创建 Redfish 密钥之前,Kepler 部署将不会继续。您可以在 Kepler 实例的 status 中找到此信息。