Skip to content

Commit b67c8ac

Browse files
authored
Allow configuring proxy trace export protocol (#13099)
Allows setting the trace export protocol env var (`LINKERD2_PROXY_TRACE_PROTOCOL`) on instances of the proxy using the existing mechanisms we have today for setting the trace collector endpoint (helm values, annotations, etc.). Currently defaults the protocol to `opencensus` to match the behavior we have today. \#10111 Signed-off-by: Scott Fleener <[email protected]>
1 parent f804357 commit b67c8ac

File tree

9 files changed

+52
-17
lines changed

9 files changed

+52
-17
lines changed

jaeger/charts/linkerd-jaeger/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ Kubernetes: `>=1.22.0-0`
125125
| webhook.caBundle | string | `""` | Bundle of CA certificates for webhook. If not provided nor injected with cert-manager, then Helm will use the certificate generated for `webhook.crtPEM`. If `webhook.externalSecret` is set to true, this value, injectCaFrom, or injectCaFromSecret must be set, as no certificate will be generated. See the cert-manager [CA Injector Docs](https://cert-manager.io/docs/concepts/ca-injector) for more information. |
126126
| webhook.collectorSvcAccount | string | `"collector"` | service account associated with the collector instance |
127127
| webhook.collectorSvcAddr | string | `"collector.linkerd-jaeger:55678"` | collector service address for the proxies to send trace data. Points by default to the linkerd-jaeger collector |
128+
| webhook.collectorTraceProtocol | string | `"opencensus"` | protocol proxies should use to send trace data. Can be `opencensus` (default) or `opentelemetry` |
128129
| webhook.crtPEM | string | `""` | Certificate for the webhook. If not provided and not using an external secret then Helm will generate one. |
129130
| webhook.externalSecret | bool | `false` | Do not create a secret resource for the webhook. If this is set to `true`, the value `webhook.caBundle` must be set or the ca bundle must injected with cert-manager ca injector using `webhook.injectCaFrom` or `webhook.injectCaFromSecret` (see below). |
130131
| webhook.failurePolicy | string | `"Ignore"` | |

jaeger/charts/linkerd-jaeger/templates/jaeger-injector.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ spec:
5050
containers:
5151
- args:
5252
- -collector-svc-addr={{.Values.webhook.collectorSvcAddr}}
53+
- -collector-trace-protocol={{.Values.webhook.collectorTraceProtocol}}
5354
- -collector-svc-account={{.Values.webhook.collectorSvcAccount}}
5455
- -log-level={{.Values.webhook.logLevel}}
5556
- -cluster-domain={{.Values.clusterDomain}}

jaeger/charts/linkerd-jaeger/values.yaml

+7-1
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ collector:
102102
config:
103103
receivers:
104104
opencensus:
105+
otlp:
106+
protocols:
107+
grpc:
105108
processors:
106109
batch:
107110
resource:
@@ -177,7 +180,7 @@ collector:
177180
extensions: [health_check]
178181
pipelines:
179182
traces:
180-
receivers: [opencensus]
183+
receivers: [opencensus, otlp]
181184
processors: [resource, k8sattributes, batch]
182185
exporters: [jaeger]
183186

@@ -290,6 +293,9 @@ webhook:
290293
# -- collector service address for the proxies to send trace data.
291294
# Points by default to the linkerd-jaeger collector
292295
collectorSvcAddr: collector.linkerd-jaeger:55678
296+
# -- protocol proxies should use to send trace data.
297+
# Can be `opencensus` (default) or `opentelemetry`
298+
collectorTraceProtocol: opencensus
293299
# -- service account associated with the collector instance
294300
collectorSvcAccount: collector
295301

jaeger/cmd/testdata/install_collector_disabled.golden

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jaeger/cmd/testdata/install_default.golden

+6-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jaeger/cmd/testdata/install_jaeger_disabled.golden

+6-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jaeger/injector/cmd/main.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ func main() {
2020
kubeconfig := cmd.String("kubeconfig", "", "path to kubeconfig")
2121
collectorSvcAddr := cmd.String("collector-svc-addr", "",
2222
"collector service address for the proxies to send trace data")
23+
collectorTraceProtocol := cmd.String("collector-trace-protocol", "",
24+
"protocol proxies should use to send trace data.")
2325
collectorSvcAccount := cmd.String("collector-svc-account", "",
2426
"service account associated with the collector instance")
2527
clusterDomain := cmd.String("cluster-domain", "cluster.local", "kubernetes cluster domain")
@@ -31,7 +33,7 @@ func main() {
3133
webhook.Launch(
3234
context.Background(),
3335
[]k8s.APIResource{k8s.NS},
34-
mutator.Mutate(*collectorSvcAddr, *collectorSvcAccount, *clusterDomain, *linkerdNamespace),
36+
mutator.Mutate(*collectorSvcAddr, *collectorTraceProtocol, *collectorSvcAccount, *clusterDomain, *linkerdNamespace),
3537
"linkerd-jaeger-injector",
3638
*metricsAddr,
3739
*addr,

jaeger/injector/mutator/patch.go

+8
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ const tpl = `[
2222
"value": "{{.CollectorSvcAddr}}"
2323
}
2424
},
25+
{
26+
"op": "add",
27+
"path": "/spec/{{.ProxyPath}}/env/-",
28+
"value": {
29+
"name": "LINKERD2_PROXY_TRACE_PROTOCOL",
30+
"value": "{{.CollectorTraceProtocol}}"
31+
}
32+
},
2533
{
2634
"op": "add",
2735
"path": "/spec/{{.ProxyPath}}/env/-",

jaeger/injector/mutator/webhook.go

+19-13
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,25 @@ import (
2020
)
2121

2222
const (
23-
collectorSvcAddrAnnotation = l5dLabels.ProxyConfigAnnotationsPrefix + "/trace-collector"
24-
collectorSvcAccountAnnotation = l5dLabels.ProxyConfigAnnotationsPrefixAlpha +
23+
collectorSvcAddrAnnotation = l5dLabels.ProxyConfigAnnotationsPrefix + "/trace-collector"
24+
collectorTraceProtocolAnnotation = l5dLabels.ProxyConfigAnnotationsPrefix + "/trace-collector-protocol"
25+
collectorSvcAccountAnnotation = l5dLabels.ProxyConfigAnnotationsPrefixAlpha +
2526
"/trace-collector-service-account"
2627
)
2728

2829
// Params holds the values used in the patch template
2930
type Params struct {
30-
ProxyPath string
31-
CollectorSvcAddr string
32-
CollectorSvcAccount string
33-
ClusterDomain string
34-
LinkerdNamespace string
31+
ProxyPath string
32+
CollectorSvcAddr string
33+
CollectorTraceProtocol string
34+
CollectorSvcAccount string
35+
ClusterDomain string
36+
LinkerdNamespace string
3537
}
3638

3739
// Mutate returns an AdmissionResponse containing the patch, if any, to apply
3840
// to the proxy
39-
func Mutate(collectorSvcAddr, collectorSvcAccount, clusterDomain, linkerdNamespace string) webhook.Handler {
41+
func Mutate(collectorSvcAddr, collectorTraceProtocol, collectorSvcAccount, clusterDomain, linkerdNamespace string) webhook.Handler {
4042
return func(
4143
_ context.Context,
4244
api *k8s.MetadataAPI,
@@ -59,11 +61,12 @@ func Mutate(collectorSvcAddr, collectorSvcAccount, clusterDomain, linkerdNamespa
5961
return nil, err
6062
}
6163
params := Params{
62-
ProxyPath: webhook.GetProxyContainerPath(pod.Spec),
63-
CollectorSvcAddr: collectorSvcAddr,
64-
CollectorSvcAccount: collectorSvcAccount,
65-
ClusterDomain: clusterDomain,
66-
LinkerdNamespace: linkerdNamespace,
64+
ProxyPath: webhook.GetProxyContainerPath(pod.Spec),
65+
CollectorSvcAddr: collectorSvcAddr,
66+
CollectorTraceProtocol: collectorTraceProtocol,
67+
CollectorSvcAccount: collectorSvcAccount,
68+
ClusterDomain: clusterDomain,
69+
LinkerdNamespace: linkerdNamespace,
6770
}
6871
if params.ProxyPath == "" || labels.IsTracingEnabled(pod) {
6972
return admissionResponse, nil
@@ -104,6 +107,9 @@ func applyOverrides(ns metav1.Object, pod *corev1.Pod, params *Params) {
104107
if override, ok := ann[collectorSvcAddrAnnotation]; ok {
105108
params.CollectorSvcAddr = override
106109
}
110+
if override, ok := ann[collectorTraceProtocolAnnotation]; ok {
111+
params.CollectorTraceProtocol = override
112+
}
107113
if override, ok := ann[collectorSvcAccountAnnotation]; ok {
108114
params.CollectorSvcAccount = override
109115
}

0 commit comments

Comments
 (0)