安装 Alauda Build of OpenTelemetry v2

安装 Alauda Build of OpenTelemetry v2 包含以下步骤:

  • 安装 Alauda Build of OpenTelemetry v2 Operator
  • 为 OpenTelemetry Collector 创建命名空间
  • 部署 OpenTelemetry Collector 实例
NOTE

从 ACP 4.5 开始,Alauda Build of OpenTelemetry v2 更名为 Alauda Container Platform Application Observability。从 customer portal 下载插件时,请搜索 Alauda Container Platform Application Observability。更名前发布的插件包上传后,在平台中仍显示为 Alauda Build of OpenTelemetry v2。

WARNING
  • 请勿在同一 Kubernetes 集群中安装 Alauda Build of OpenTelemetry 和 Alauda Build of OpenTelemetry v2,否则会导致功能冲突。
  • 请勿在同一 Kubernetes 集群中安装 Alauda Service Mesh 和 Alauda Build of OpenTelemetry v2,否则会导致功能冲突(Alauda Service Mesh v2 支持与 Alauda Build of OpenTelemetry v2 集成)。
  • 请勿在与 Operator 相同的命名空间中部署 OpenTelemetry Collector。请为 Collector 实例创建单独的命名空间。

安装 Alauda Build of OpenTelemetry v2 Operator

通过 Web 控制台安装

前提条件

  • 必须已上传 Alauda Container Platform Application Observability(原 Alauda Build of OpenTelemetry v2)。
  • 你已以 cluster-admin 身份登录 Alauda Container Platform Web 控制台。

操作步骤

  1. 在 Alauda Container Platform Web 控制台中,导航至 Administrator。
  2. 选择 Marketplace > OperatorHub。
  3. 搜索 Alauda Container Platform Application Observability 插件(更名前发布的插件包显示为 Alauda Build of OpenTelemetry v2)。
  4. 找到 Alauda Container Platform Application Observability 插件(或 Alauda Build of OpenTelemetry v2),然后单击以选中。
  5. 单击 Install。
  6. 在 Install Alauda Container Platform Application Observability 对话框中(更名前发布的插件包标题为 Install Alauda Build of OpenTelemetry v2),执行以下步骤:
    1. 选择 stable 通道,以安装最新的稳定版 Alauda Build of OpenTelemetry v2 Operator。
  7. 单击 Install 和 Confirm 以安装 Operator。

验证

在 Installation Info 部分确认 Operator 安装状态显示为 Succeeded。

通过 CLI 安装

前提条件

  • 必须已上传 Alauda Container Platform Application Observability(原 Alauda Build of OpenTelemetry v2)。
  • 已由具有 cluster-admin 角色的集群管理员建立有效的 ACP CLI (kubectl) 会话。

操作步骤

  1. 查看可用版本

    (
      echo -e "CHANNEL\tNAME\tVERSION"
      kubectl get packagemanifest opentelemetry-operator2 -o json | jq -r '
        .status.channels[] |
        .name as $channel |
        .entries[] |
        [$channel, .name, .version] | @tsv
      '
    ) | column -t -s $'\t'

    输出示例

    CHANNEL  NAME                                    VERSION
    stable   opentelemetry-operator2.v0.147.0-r0     0.147.0-r0

    字段:

    • CHANNEL:Operator 通道名称
    • NAME:CSV 资源名称
    • VERSION:Operator 版本
  2. 确认 catalogSource

    kubectl get packagemanifests opentelemetry-operator2 -ojsonpath='{.status.catalogSource}'

    输出示例

    platform

    这表示 opentelemetry-operator2 来自 platform catalogSource。

  3. 创建命名空间

    kubectl get namespace opentelemetry-operator2 || kubectl create namespace opentelemetry-operator2
  4. 创建 Subscription

    kubectl apply -f - <<EOF
    apiVersion: operators.coreos.com/v1alpha1
    kind: Subscription
    metadata:
      annotations:
        cpaas.io/target-namespaces: ""
      labels:
        catalog: platform
      name: opentelemetry-operator2
      namespace: opentelemetry-operator2
    spec:
      channel: stable
      installPlanApproval: Manual
      name: opentelemetry-operator2
      source: platform
      sourceNamespace: cpaas-system
      startingCSV: opentelemetry-operator2.v0.147.0-r0
    EOF

    字段说明

    • annotation cpaas.io/target-namespaces:建议将其设置为空;空值表示集群范围安装。
    • .metadata.name:Subscription 名称(符合 DNS 规范,最多 253 个字符)。
    • .metadata.namespace:安装 Operator 的命名空间。
    • .spec.channel:订阅的 Operator 通道。
    • .spec.installPlanApproval:审批策略(Manual 或 Automatic)。此处,Manual 表示安装/升级需要手动审批。
    • .spec.source:Operator catalogSource。
    • .spec.sourceNamespace:必须设置为 cpaas-system,因为平台提供的所有 catalogSource 均位于此命名空间中。
    • .spec.startingCSV:指定要安装的版本(适用于 Manual 审批);若为空,则默认为通道中的最新版本。Automatic 模式下无需设置。
  5. 检查 Subscription 状态

    kubectl -n opentelemetry-operator2 get subscriptions opentelemetry-operator2 -o yaml

    关键输出

    • .status.state:UpgradePending 表示 Operator 正在等待安装或升级。
    • Condition InstallPlanPending = True:等待手动审批。
    • .status.currentCSV:最新订阅的 CSV。
    • .status.installPlanRef:关联的 InstallPlan;继续安装前必须先批准。

    等待 InstallPlanPending 条件变为 True:

    kubectl -n opentelemetry-operator2 wait --for=condition=InstallPlanPending subscription opentelemetry-operator2 --timeout=2m
  6. 批准 InstallPlan

    kubectl -n opentelemetry-operator2 get installplan \
      "$(kubectl -n opentelemetry-operator2 get subscriptions opentelemetry-operator2 -o jsonpath='{.status.installPlanRef.name}')"

    输出示例

    NAME            CSV                                     APPROVAL   APPROVED
    install-abc12   opentelemetry-operator2.v0.147.0-r0     Manual     false

    手动批准

    PLAN="$(kubectl -n opentelemetry-operator2 get subscription opentelemetry-operator2 -o jsonpath='{.status.installPlanRef.name}')"
    kubectl -n opentelemetry-operator2 patch installplan "$PLAN" --type=json -p='[{"op": "replace", "path": "/spec/approved", "value": true}]'

验证

等待 CSV 创建;Phase 变为 Succeeded:

kubectl wait --for=jsonpath='{.status.phase}'=Succeeded csv --all -n opentelemetry-operator2 --timeout=3m

检查 CSV 状态:

kubectl -n opentelemetry-operator2 get csv

输出示例

NAME                                    DISPLAY                                  VERSION      REPLACES   PHASE
opentelemetry-operator2.v0.147.0-r0     Alauda Build of OpenTelemetry v2         0.147.0-r0              Succeeded

字段

  • NAME:已安装的 CSV 名称
  • DISPLAY:Operator 显示名称
  • VERSION:Operator 版本
  • REPLACES:升级过程中被替换的 CSV
  • PHASE:安装状态(Succeeded 表示成功)

部署 OpenTelemetry Collector

成功安装 Alauda Build of OpenTelemetry v2 Operator 后,通过创建 OpenTelemetryCollector 自定义资源来部署 OpenTelemetry Collector。

NOTE

多个 OpenTelemetry Collector 实例可以在不同的命名空间中共存。每个实例相互独立,并由 Operator 管理。

为 Collector 创建命名空间

部署 OpenTelemetry Collector 之前,请为 Collector 实例创建专用命名空间。Collector 不得部署在与 Operator 相同的命名空间中。

TIP

本指南中使用的 opentelemetry-collector 命名空间仅为示例。你可以创建并使用符合组织命名规范的任意名称的命名空间。

kubectl get namespace opentelemetry-collector || \
  kubectl create namespace opentelemetry-collector

通过 Web 控制台部署

前提条件

  • 必须已安装 Alauda Container Platform Application Observability(之前称为 Alauda Build of OpenTelemetry v2)Operator。
  • 你已使用 cluster-admin 身份登录 Alauda Container Platform Web 控制台。
  • 已为 Collector 实例创建专用命名空间。

操作步骤

  1. 在 Alauda Container Platform Web 控制台中,导航到 Administrator。

  2. 选择 Marketplace > OperatorHub。

  3. 搜索 Alauda Container Platform Application Observability 插件(对于重命名前发布的软件包,该插件显示为 Alauda Build of OpenTelemetry v2)。

  4. 找到 Alauda Container Platform Application Observability 插件(或 Alauda Build of OpenTelemetry v2),然后单击以选中它。

  5. 单击 All Instances 选项卡。

  6. 单击 Create。

  7. 找到并选择 OpenTelemetryCollector,然后单击 Create。

  8. 从 Namespace 下拉菜单中选择 Collector 命名空间。

  9. 单击 YAML 选项卡。

  10. 在 YAML 代码编辑器中自定义 OpenTelemetryCollector 自定义资源(CR):

    OpenTelemetryCollector CR 示例

    apiVersion: opentelemetry.io/v1beta1
    kind: OpenTelemetryCollector
    metadata:
      name: otel
      namespace: opentelemetry-collector
    spec:
      mode: deployment
      replicas: 1
      config:
        receivers:
          otlp:
            protocols:
              grpc: {}
              http: {}
          jaeger:
            protocols:
              grpc: {}
              thrift_binary: {}
              thrift_compact: {}
              thrift_http: {}
          zipkin: {}
        processors:
          batch: {}
          memory_limiter:
            check_interval: 1s
            limit_percentage: 80
            spike_limit_percentage: 20
        exporters:
          debug: {}
        service:
          pipelines:
            traces:
              receivers: [otlp, jaeger, zipkin]
              processors: [memory_limiter, batch]
              exporters: [debug]
    1. 部署 OpenTelemetry Collector 实例的命名空间。此处以 opentelemetry-collector 为例;请将其替换为你为 Collector 创建的命名空间。此命名空间必须与 Operator 的命名空间不同。
    2. Collector 部署模式。支持的值:deployment(默认)、daemonset、statefulset 或 sidecar。
    3. Receiver 定义遥测数据进入 Collector 的方式。此示例配置了 OTLP、Jaeger 和 Zipkin 协议 receiver。
    4. Processor 负责处理接收与导出之间的数据。此示例使用 batch 批处理遥测数据,并使用 memory_limiter 控制内存使用量。
    5. Exporter 定义遥测数据的目标位置。此示例使用 debug exporter,将数据输出到 Collector 日志。
  11. 单击 Create。

验证

等待 OpenTelemetry Collector 的 pod 运行。

通过 CLI 部署

前提条件

  • 集群管理员已建立有效的 ACP CLI (kubectl) 会话,并具有 cluster-admin 角色。
  • 必须已安装 Alauda Container Platform Application Observability(之前称为 Alauda Build of OpenTelemetry v2)Operator。
  • 已为 Collector 实例创建专用命名空间。

操作步骤

  1. 自定义并应用 OpenTelemetryCollector 自定义资源(CR):

    kubectl apply -f - <<EOF
    apiVersion: opentelemetry.io/v1beta1
    kind: OpenTelemetryCollector
    metadata:
      name: otel
      namespace: opentelemetry-collector
    spec:
      mode: deployment
      replicas: 1
      config:
        receivers:
          otlp:
            protocols:
              grpc: {}
              http: {}
          jaeger:
            protocols:
              grpc: {}
              thrift_binary: {}
              thrift_compact: {}
              thrift_http: {}
          zipkin: {}
        processors:
          batch: {}
          memory_limiter:
            check_interval: 1s
            limit_percentage: 80
            spike_limit_percentage: 20
        exporters:
          debug: {}
        service:
          pipelines:
            traces:
              receivers: [otlp, jaeger, zipkin]
              processors: [memory_limiter, batch]
              exporters: [debug]
    EOF
    NOTE

    有关 OpenTelemetryCollector CR 字段的详细说明,请参阅上文通过 Web 控制台部署部分中的 CR 示例。

  2. 等待 Collector pod 就绪:

    kubectl wait --for=condition=Ready pod -l app.kubernetes.io/managed-by=opentelemetry-operator -n opentelemetry-collector --timeout=3m

验证

检查 Collector pod 是否正在运行:

kubectl get pods -n opentelemetry-collector

输出示例

NAME                              READY   STATUS    RESTARTS   AGE
otel-collector-7877b4cdcf-bj7br   1/1     Running   0          69s

卸载

要从集群中移除 Alauda Distributed Tracing 组件,请按照卸载 Alauda Build of OpenTelemetry v2中的说明操作。