简体   繁体   English

Linkerd 使用 OpenCensus 进行分布式跟踪

[英]Linkerd distributed tracing with OpenCensus

Context语境

I am trying to use OpenCensus and Linkerd.我正在尝试使用 OpenCensus 和 Linkerd。 Though Linkerd has an option to automatically provision OpenCensus and jaeger in its namespace, I don't want to use them.尽管 Linkerd 可以选择在其命名空间中自动配置 OpenCensus 和 jaeger,但我不想使用它们。 Instead, I deployed them independently by myself under the namespace named 'ops'.相反,我自己在名为“ops”的命名空间下独立部署了它们。

Questions问题

  1. Whether OpenCensus collector should be injected by Linkerd. OpenCensus 收集器是否应该由 Linkerd 注入。

At the end (exactly 4th line from the last) of the the official docs , it says,在官方文档的最后(正好是最后的第 4 行),它说,

Ensure the OpenCensus collector is injected with the Linkerd proxy.确保 OpenCensus 收集器注入了 Linkerd 代理。

What does this mean?这是什么意思?
Should I inject linkerd sidecar into OpenCensus collector pod?我应该将 linkerd sidecar 注入 OpenCensus 收集器 pod 吗?
If so, why?如果是这样,为什么?

  1. Should I suffix serviceaccount name by namespace?我应该按命名空间为 serviceaccount 名称添加后缀吗?

For example, let's say I've configured the default namespace like this.例如,假设我已经像这样配置了默认命名空间。

apiVersion: v1
kind: Namespace
metadata:
  name: default
  annotations:
    linkerd.io/inject: enabled
    config.linkerd.io/trace-collector: my-opencensus-collector.ops:12345
    config.alpha.linkerd.io/trace-collector-service-account: my-opencensus-collector-service-account

my-opencensus-collector is in ops namespace, so I put .ops at the end of its service name, resulting my-opencensus-collector.ops:12345 . my-opencensus-collector位于ops命名空间中,因此我将.ops放在其服务名称的末尾,从而产生my-opencensus-collector.ops:12345 And the dedicated service account for the OpenCensus collector exists in ops namespace, too. OpenCensus 收集器的专用服务帐户也存在于ops命名空间中。 In this case, should I put the namespace name at the end of service account name as well?在这种情况下,我是否也应该将命名空间名称放在服务帐户名称的末尾?

Which one would be right?哪一个是对的?

config.alpha.linkerd.io/trace-collector-service-account: my-opencensus-collector-service-account

or或者

config.alpha.linkerd.io/trace-collector-service-account: my-opencensus-collector-service-account.ops

Thanks!谢谢!

  1. Whether OpenCensus collector should be injected by Linkerd. OpenCensus 收集器是否应该由 Linkerd 注入。

Yes, the OpenCensus collector should be injected with the Linkerd proxy because the proxies themselves send the span info using mTLS.是的,OpenCensus 收集器应该注入 Linkerd 代理,因为代理本身使用 mTLS 发送跨度信息。 With mTLS, the sending (client) and receiving (server) sides of the request must present certificates to each other in to verify that identities to each other in a way that validates that the identity was issued by the same trusted source.使用 mTLS,请求的发送端(客户端)和接收端(服务器端)必须向对方出示证书,以验证身份是由同一可信来源颁发的。

The Linkerd service mesh is made up of the control plane and the data plane. Linkerd 服务网格由控制平面和数据平面组成。 The control plane is a set of services that run within the cluster to implement the features of the service mesh.控制平面是在集群内运行以实现服务网格特性的一组服务。 Mutual TLS (mTLS) is one of those features and is implemented by the linkerd-identity component of the control plane. Mutual TLS (mTLS) 是这些功能之一,由控制平面的linkerd-identity组件实现。

The data plane is comprised of any number of the Linkerd proxies which are injected into the services in the application, like the OpenCensus collector.数据平面由任意数量的 Linkerd 代理组成,这些代理被注入到应用程序的服务中,例如 OpenCensus 收集器。 Whenever a proxy is started within a pod, it sends a certificate signing request to the linkerd-identity component and receives a certificate in return.每当在 Pod 中启动代理时,它都会向linkerd-identity组件发送证书签名请求并接收证书作为回报。

So, when the Linkerd proxies in the control plane send the spans to the collector, they authenticate themselves with those certificates, which must be verified by the proxy injected into the OpenCensus collector Pod.因此,当控制平面中的 Linkerd 代理将 span 发送到收集器时,它们会使用这些证书对自己进行身份验证,这些证书必须由注入 OpenCensus 收集器 Pod 的代理进行验证。 This ensures that all traffic, even distributed traces, are sent securely within the cluster.这确保了所有流量,甚至是分布式跟踪,都在集群内安全地发送。

  1. Should I suffix serviceaccount name by namespace?我应该按命名空间为 serviceaccount 名称添加后缀吗?

In your case, you should suffix the service account with the namespace.在您的情况下,您应该使用命名空间为服务帐户添加后缀。 By default, Linkerd will use the Pod namespace, so if the service account doesn't exist in the Pod namespace, then the configuration will be invalid.默认情况下,Linkerd 将使用 Pod 命名空间,因此如果 Pod 命名空间中不存在服务帐户,则配置将无效。 The logic has a function that checks for a namespace in the annotation name and appends it, if it exists:逻辑有一个 function 检查注解名称中的命名空间并附加它(如果存在):

func ammendSvcAccount(ns string, params *Params) {
    hostAndPort := strings.Split(params.CollectorSvcAddr, ":")
    hostname := strings.Split(hostAndPort[0], ".")
    if len(hostname) > 1 {
        ns = hostname[1]
    }
    params.CollectorSvcAccount = fmt.Sprintf("%s.%s", params.CollectorSvcAccount, ns)
}

So, this one is correct:所以,这个是正确的:

config.alpha.linkerd.io/trace-collector-service-account: my-opencensus-collector-service-account.ops

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM