11.2. 在没有 sidecar 的情况下迁移


您可以从分布式追踪平台(Jaeger)迁移到没有 sidecar 部署的红帽构建的 OpenTelemetry。

先决条件

  • 在集群中使用 Red Hat OpenShift distributed tracing Platform (Jaeger)。
  • 已安装红帽构建的 OpenTelemetry。

流程

  1. 配置 OpenTelemetry Collector 部署。
  2. 创建部署 OpenTelemetry Collector 的项目。

    apiVersion: project.openshift.io/v1
    kind: Project
    metadata:
      name: observability
  3. 创建用于运行 OpenTelemetry Collector 实例的服务帐户。

    apiVersion: v1
    kind: ServiceAccount
    metadata:
      name: otel-collector-deployment
      namespace: observability
  4. 创建集群角色,以设置处理器所需的权限。

    apiVersion: rbac.authorization.k8s.io/v1
    kind: ClusterRole
    metadata:
      name: otel-collector
    rules:
      1
      2
    - apiGroups: ["", "config.openshift.io"]
      resources: ["pods", "namespaces", "infrastructures", "infrastructures/status"]
      verbs: ["get", "watch", "list"]
    1
    k8sattributesprocessor 需要 podsnamespaces 资源的权限。
    2
    resourcedetectionprocessor 需要 infrastructuresinfrastructures/status 的权限。
  5. 创建 ClusterRoleBinding 来为服务帐户设置权限。

    apiVersion: rbac.authorization.k8s.io/v1
    kind: ClusterRoleBinding
    metadata:
      name: otel-collector
    subjects:
    - kind: ServiceAccount
      name: otel-collector-deployment
      namespace: observability
    roleRef:
      kind: ClusterRole
      name: otel-collector
      apiGroup: rbac.authorization.k8s.io
  6. 创建 OpenTelemetry Collector 实例。

    注意

    此收集器会将 trace 导出至 TempoStack 实例。您必须使用 Red Hat Tempo Operator 创建 TempoStack 实例,并放在正确的端点中。

    apiVersion: opentelemetry.io/v1beta1
    kind: OpenTelemetryCollector
    metadata:
      name: otel
      namespace: observability
    spec:
      mode: deployment
      serviceAccount: otel-collector-deployment
      config:
        receivers:
          jaeger:
            protocols:
              grpc: {}
              thrift_binary: {}
              thrift_compact: {}
              thrift_http: {}
        processors:
          batch: {}
          k8sattributes: {}
          memory_limiter:
            check_interval: 1s
            limit_percentage: 50
            spike_limit_percentage: 30
          resourcedetection:
            detectors: [openshift]
        exporters:
          otlp:
            endpoint: "tempo-example-gateway:8090"
            tls:
              insecure: true
        service:
          pipelines:
            traces:
              receivers: [jaeger]
              processors: [memory_limiter, k8sattributes, resourcedetection, batch]
              exporters: [otlp]
  7. 将追踪端点指向 OpenTelemetry Operator。
  8. 如果您要将 trace 直接从应用程序导出到 Jaeger,请将 API 端点从 Jaeger 端点改为 OpenTelemetry Collector 端点。

    使用带有 Golang 的 jaegerexporter 导出 trace 的示例

    exp, err := jaeger.New(jaeger.WithCollectorEndpoint(jaeger.WithEndpoint(url))) 1

    1
    URL 指向 OpenTelemetry Collector API 端点。
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.