安装 Alauda Build of OpenTelemetry v2

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

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

安装 Alauda Build of OpenTelemetry v2 Operator

通过 Web 控制台安装

前提条件

  • 已上传 Alauda Build of OpenTelemetry v2。
  • 您已使用 cluster-admin 身份登录 Alauda Container Platform Web 控制台。

操作步骤

  1. 在 Alauda Container Platform Web 控制台中,进入 Administrator
  2. 选择 Marketplace > OperatorHub
  3. 搜索 Alauda Build of OpenTelemetry v2。
  4. 找到 Alauda Build of OpenTelemetry v2,并单击选中。
  5. 单击 Install
  6. Install Alauda Build of OpenTelemetry v2 对话框中,执行以下步骤:
    1. 选择 stable channel,以安装最新稳定版本的 Alauda Build of OpenTelemetry v2 Operator。
  7. 单击 InstallConfirm,以安装 Operator。

验证

确认 Installation Info 部分中的 Operator 安装状态显示为 Succeeded

通过 CLI 安装

前提条件

  • 已上传 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.157.0-r1     0.157.0-r1

    字段

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

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

    示例输出

    platform

    这表明 opentelemetry-operator2 来自 platform catalogSource。

  3. 创建 namespace

    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.157.0-r1
    EOF

    字段说明

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

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

    关键输出

    • .status.stateUpgradePending 表示 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.157.0-r1     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.157.0-r1     Alauda Build of OpenTelemetry v2         0.157.0-r1              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 实例可以共存于不同的 namespace 中。每个实例都是独立的,并由 Operator 管理。

为 Collector 创建 namespace

在部署 OpenTelemetry Collector 之前,请为 Collector 实例创建一个专用的 namespace。Collector 不能部署在与 Operator 相同的 namespace 中。

TIP

本指南中使用的 opentelemetry-collector namespace 仅为示例。您可以创建并使用任何符合组织命名规范的 namespace。

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

通过 Web 控制台部署

前提条件

  • 已安装 Alauda Build of OpenTelemetry v2 Operator。
  • 您已使用 cluster-admin 身份登录 Alauda Container Platform Web 控制台。
  • 已为 Collector 实例创建专用的 namespace。

操作步骤

  1. 在 Alauda Container Platform Web 控制台中,进入 Administrator

  2. 选择 Marketplace > OperatorHub

  3. 搜索 Alauda Build of OpenTelemetry v2。

  4. 找到 Alauda Build of OpenTelemetry v2,并单击选中。

  5. 单击 All Instances 选项卡。

  6. 单击 Create

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

  8. Namespace 下拉列表中选择 Collector 的 namespace。

  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 实例的 namespace。此处以 opentelemetry-collector 为例;请将其替换为您为 Collector 创建的 namespace。该 namespace 必须与 Operator 的 namespace 不同。
    2. Collector 的部署模式。支持的值:deployment(默认)、daemonsetstatefulsetsidecar
    3. Receiver 定义 telemetry 数据如何进入 Collector。此示例配置了 OTLP、Jaeger 和 Zipkin 协议 receiver。
    4. Processor 负责在接收和导出之间进行数据处理。此示例使用 batch 对 telemetry 数据进行批处理,并使用 memory_limiter 控制内存使用。
    5. Exporter 定义 telemetry 数据的目标位置。此示例使用 debug exporter,将数据输出到 Collector 日志中。
  11. 单击 Create

验证

等待 OpenTelemetry Collector 的 pod 运行起来。

通过 CLI 部署

前提条件

  • 集群管理员已使用 cluster-admin 角色建立一个活跃的 ACP CLI (kubectl) 会话。
  • 已安装 Alauda Build of OpenTelemetry v2 Operator。
  • 已为 Collector 实例创建专用的 namespace。

操作步骤

  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