Skip to content

Commit

Permalink
Add configuration for proxy trace service name (#13130)
Browse files Browse the repository at this point in the history
Companion to linkerd/linkerd2-proxy#3245, exposes the configuration for the tracing service name in the proxy to the general linkerd config.

Similar in concept to #12371, except the configuration lives entirely within the tracing injector config instead of going through the control plane.

Fixes #11157

Signed-off-by: Scott Fleener <[email protected]>
  • Loading branch information
sfleen authored Oct 11, 2024
1 parent c1d83c1 commit ff874d5
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 2 deletions.
1 change: 1 addition & 0 deletions jaeger/charts/linkerd-jaeger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ Kubernetes: `>=1.22.0-0`
| webhook.collectorSvcAccount | string | `"collector"` | service account associated with the collector instance |
| 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 |
| webhook.collectorTraceProtocol | string | `"opencensus"` | protocol proxies should use to send trace data. Can be `opencensus` (default) or `opentelemetry` |
| webhook.collectorTraceSvcName | string | `"linkerd-proxy"` | name of the service proxies should use for exported traces |
| webhook.crtPEM | string | `""` | Certificate for the webhook. If not provided and not using an external secret then Helm will generate one. |
| 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). |
| webhook.failurePolicy | string | `"Ignore"` | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ spec:
- args:
- -collector-svc-addr={{.Values.webhook.collectorSvcAddr}}
- -collector-trace-protocol={{.Values.webhook.collectorTraceProtocol}}
- -collector-trace-svc-name={{.Values.webhook.collectorTraceSvcName}}
- -collector-svc-account={{.Values.webhook.collectorSvcAccount}}
- -log-level={{.Values.webhook.logLevel}}
- -cluster-domain={{.Values.clusterDomain}}
Expand Down
2 changes: 2 additions & 0 deletions jaeger/charts/linkerd-jaeger/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,8 @@ webhook:
# -- protocol proxies should use to send trace data.
# Can be `opencensus` (default) or `opentelemetry`
collectorTraceProtocol: opencensus
# -- name of the service proxies should use for exported traces
collectorTraceSvcName: linkerd-proxy
# -- service account associated with the collector instance
collectorSvcAccount: collector

Expand Down
1 change: 1 addition & 0 deletions jaeger/cmd/testdata/install_collector_disabled.golden

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions jaeger/cmd/testdata/install_default.golden

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions jaeger/cmd/testdata/install_jaeger_disabled.golden

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion jaeger/injector/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ func main() {
"collector service address for the proxies to send trace data")
collectorTraceProtocol := cmd.String("collector-trace-protocol", "",
"protocol proxies should use to send trace data.")
collectorTraceSvcName := cmd.String("collector-trace-svc-name", "",
"name of the service proxies should use for exported traces.")
collectorSvcAccount := cmd.String("collector-svc-account", "",
"service account associated with the collector instance")
clusterDomain := cmd.String("cluster-domain", "cluster.local", "kubernetes cluster domain")
Expand All @@ -33,7 +35,7 @@ func main() {
webhook.Launch(
context.Background(),
[]k8s.APIResource{k8s.NS},
mutator.Mutate(*collectorSvcAddr, *collectorTraceProtocol, *collectorSvcAccount, *clusterDomain, *linkerdNamespace),
mutator.Mutate(*collectorSvcAddr, *collectorTraceProtocol, *collectorTraceSvcName, *collectorSvcAccount, *clusterDomain, *linkerdNamespace),
"linkerd-jaeger-injector",
*metricsAddr,
*addr,
Expand Down
8 changes: 8 additions & 0 deletions jaeger/injector/mutator/patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ const tpl = `[
"value": "{{.CollectorTraceProtocol}}"
}
},
{
"op": "add",
"path": "/spec/{{.ProxyPath}}/env/-",
"value": {
"name": "LINKERD2_PROXY_TRACE_SERVICE_NAME",
"value": "{{.CollectorTraceSvcName}}"
}
},
{
"op": "add",
"path": "/spec/{{.ProxyPath}}/env/-",
Expand Down
8 changes: 7 additions & 1 deletion jaeger/injector/mutator/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
const (
collectorSvcAddrAnnotation = l5dLabels.ProxyConfigAnnotationsPrefix + "/trace-collector"
collectorTraceProtocolAnnotation = l5dLabels.ProxyConfigAnnotationsPrefix + "/trace-collector-protocol"
collectorTraceSvcNameAnnotation = l5dLabels.ProxyConfigAnnotationsPrefix + "/trace-collector-name"
collectorSvcAccountAnnotation = l5dLabels.ProxyConfigAnnotationsPrefixAlpha +
"/trace-collector-service-account"
)
Expand All @@ -31,14 +32,15 @@ type Params struct {
ProxyPath string
CollectorSvcAddr string
CollectorTraceProtocol string
CollectorTraceSvcName string
CollectorSvcAccount string
ClusterDomain string
LinkerdNamespace string
}

// Mutate returns an AdmissionResponse containing the patch, if any, to apply
// to the proxy
func Mutate(collectorSvcAddr, collectorTraceProtocol, collectorSvcAccount, clusterDomain, linkerdNamespace string) webhook.Handler {
func Mutate(collectorSvcAddr, collectorTraceProtocol, collectorTraceSvcName, collectorSvcAccount, clusterDomain, linkerdNamespace string) webhook.Handler {
return func(
_ context.Context,
api *k8s.MetadataAPI,
Expand All @@ -64,6 +66,7 @@ func Mutate(collectorSvcAddr, collectorTraceProtocol, collectorSvcAccount, clust
ProxyPath: webhook.GetProxyContainerPath(pod.Spec),
CollectorSvcAddr: collectorSvcAddr,
CollectorTraceProtocol: collectorTraceProtocol,
CollectorTraceSvcName: collectorTraceSvcName,
CollectorSvcAccount: collectorSvcAccount,
ClusterDomain: clusterDomain,
LinkerdNamespace: linkerdNamespace,
Expand Down Expand Up @@ -110,6 +113,9 @@ func applyOverrides(ns metav1.Object, pod *corev1.Pod, params *Params) {
if override, ok := ann[collectorTraceProtocolAnnotation]; ok {
params.CollectorTraceProtocol = override
}
if override, ok := ann[collectorTraceSvcNameAnnotation]; ok {
params.CollectorTraceSvcName = override
}
if override, ok := ann[collectorSvcAccountAnnotation]; ok {
params.CollectorSvcAccount = override
}
Expand Down

0 comments on commit ff874d5

Please sign in to comment.