Skip to content

Commit 62c78bc

Browse files
committed
feat(tracing): Add proxy tracing configuration to control plane helm chart
Previously, this would require the `linkerd-jaeger` extension to be installed. This comes with its own set of issues, namely managing yet another component of linkerd. Since the tracing config is basically just environment variables and one volume mount, hoisting them up into the main control plane helm chart for the proxy injector to handle is likely the simplest and most maintainable path going forward. The injector from the `linkerd-jaeger` extension will still work for the time being, and is interoprable to some degree as long as the injector in the extension is disabled. A follow-up to this PR should add documentation around this and how users can migrate from the extension to these configs. Signed-off-by: Scott Fleener <[email protected]>
1 parent bd0bb78 commit 62c78bc

30 files changed

+359
-2
lines changed

charts/linkerd-control-plane/templates/destination.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -447,3 +447,6 @@ spec:
447447
- {{- include "partials.proxy.volumes.service-account-token" . | indent 8 | trimPrefix (repeat 7 " ") }}
448448
{{ end -}}
449449
- {{- include "partials.proxy.volumes.identity" . | indent 8 | trimPrefix (repeat 7 " ") }}
450+
{{if .Values.proxy.tracing.enabled -}}
451+
- {{- include "partials.proxy.volumes.podinfo" . | indent 8 | trimPrefix (repeat 7 " ") }}
452+
{{ end }}

charts/linkerd-control-plane/templates/identity.yaml

+4-1
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,11 @@ spec:
270270
{{ if not .Values.cniEnabled -}}
271271
- {{- include "partials.proxyInit.volumes.xtables" . | indent 8 | trimPrefix (repeat 7 " ") }}
272272
{{ end -}}
273-
{{if .Values.identity.serviceAccountTokenProjection -}}
273+
{{ if .Values.identity.serviceAccountTokenProjection -}}
274274
- {{- include "partials.proxy.volumes.service-account-token" . | indent 8 | trimPrefix (repeat 7 " ") }}
275275
{{ end -}}
276276
- {{- include "partials.proxy.volumes.identity" . | indent 8 | trimPrefix (repeat 7 " ") }}
277+
{{ if .Values.proxy.tracing.enabled -}}
278+
- {{- include "partials.proxy.volumes.podinfo" . | indent 8 | trimPrefix (repeat 7 " ") }}
279+
{{ end }}
277280
{{end -}}

charts/linkerd-control-plane/templates/proxy-injector.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,9 @@ spec:
185185
- {{- include "partials.proxy.volumes.service-account-token" . | indent 8 | trimPrefix (repeat 7 " ") }}
186186
{{ end -}}
187187
- {{- include "partials.proxy.volumes.identity" . | indent 8 | trimPrefix (repeat 7 " ") }}
188+
{{if .Values.proxy.tracing.enabled -}}
189+
- {{- include "partials.proxy.volumes.podinfo" . | indent 8 | trimPrefix (repeat 7 " ") }}
190+
{{ end }}
188191
---
189192
kind: Service
190193
apiVersion: v1

charts/linkerd-control-plane/values.yaml

+14
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,20 @@ proxy:
284284
metrics:
285285
# -- Whether or not to export hostname labels in outbound request metrics.
286286
hostnameLabels: false
287+
# Configures tracing in the proxy and how they are exported
288+
tracing:
289+
# -- Enables trace collection and export in the proxy
290+
enable: false
291+
# -- Protocol to export traces with. Currently supported are
292+
# "opentelemetry" (default) and "opencensus" (deprecated)
293+
protocol: opentelemetry
294+
traceServiceName: linkerd-proxy
295+
collector:
296+
# -- The collector endpoint to send traces to.
297+
endpoint: ""
298+
# -- The identity of the collector in the linkerd mesh. If the collector
299+
# is unmeshed (recommended), this should remain unset.
300+
meshIdentity: ""
287301
inbound:
288302
server:
289303
http2:

charts/partials/templates/_proxy.tpl

+22
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,24 @@ env:
144144
value: 30s
145145
- name: LINKERD2_PROXY_OUTBOUND_METRICS_HOSTNAME_LABELS
146146
value: {{ .Values.proxy.metrics.hostnameLabels | quote }}
147+
{{ if .Values.proxy.tracing.enable -}}
148+
- name: LINKERD2_PROXY_TRACE_ATTRIBUTES_PATH
149+
value: /var/run/linkerd/podinfo/labels
150+
- name: LINKERD2_PROXY_TRACE_PROTOCOL
151+
value: {{ .Values.proxy.tracing.protocol }}
152+
- name: LINKERD2_PROXY_TRACE_SERVICE_NAME
153+
value: {{ .Values.proxy.tracing.traceServiceName }}
154+
- name: LINKERD2_PROXY_TRACE_COLLECTOR_SVC_ADDR
155+
value: {{ .Values.proxy.tracing.collector.endpoint }}
156+
{{ if .Values.proxy.tracing.collector.meshIdentity -}}
157+
- name: LINKERD2_PROXY_TRACE_COLLECTOR_SVC_NAME
158+
value: {{ .Values.proxy.tracing.collector.meshIdentity }}.serviceaccount.identity.{{.Release.Namespace}}.{{ .Values.clusterDomain }}
159+
{{ end -}}
160+
- name: LINKERD2_PROXY_TRACE_EXTRA_ATTRIBUTES
161+
value: |
162+
k8s.pod.uid=$(_pod_uid)
163+
k8s.container.name=$(_pod_containerName)
164+
{{ end -}}
147165
{{- /* Configure inbound and outbound parameters, e.g. for HTTP/2 servers. */}}
148166
{{ range $proxyK, $proxyV := (dict "inbound" .Values.proxy.inbound "outbound" .Values.proxy.outbound) -}}
149167
{{ range $scopeK, $scopeV := $proxyV -}}
@@ -284,6 +302,10 @@ lifecycle:
284302
volumeMounts:
285303
- mountPath: /var/run/linkerd/identity/end-entity
286304
name: linkerd-identity-end-entity
305+
{{- if .Values.proxy.tracing.enable }}
306+
- mountPath: /var/run/linkerd/podinfo
307+
name: linkerd-podinfo
308+
{{- end }}
287309
{{- if .Values.identity.serviceAccountTokenProjection }}
288310
- mountPath: /var/run/secrets/tokens
289311
name: linkerd-identity-token

charts/partials/templates/_volumes.tpl

+10-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ emptyDir:
44
name: linkerd-identity-end-entity
55
{{- end -}}
66

7+
{{- define "partials.proxy.volumes.podinfo" -}}
8+
name: linkerd-podinfo
9+
downwardAPI:
10+
items:
11+
- path: labels
12+
fieldRef:
13+
fieldPath: metadata.labels
14+
{{- end -}}
15+
716
{{ define "partials.proxyInit.volumes.xtables" -}}
817
emptyDir: {}
918
name: {{ .Values.proxyInit.xtMountPath.name }}
@@ -38,4 +47,4 @@ projected:
3847
apiVersion: v1
3948
fieldPath: metadata.namespace
4049
path: namespace
41-
{{- end -}}
50+
{{- end -}}

charts/patch/templates/patch.json

+19
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,25 @@ structs.
103103
}
104104
}
105105
},
106+
{{- if .Values.proxy.tracing.enable }}
107+
{
108+
"op": "add",
109+
"path": "{{$prefix}}/spec/volumes/-",
110+
"value": {
111+
"downwardAPI": {
112+
"items": [
113+
{
114+
"fieldRef": {
115+
"fieldPath": "metadata.labels"
116+
},
117+
"path": "labels"
118+
}
119+
]
120+
},
121+
"name": "linkerd-podinfo"
122+
}
123+
},
124+
{{- end }}
106125
{{- if .Values.identity.serviceAccountTokenProjection}}
107126
{
108127
"op": "add",

cli/cmd/install_test.go

+9
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,15 @@ func TestRender(t *testing.T) {
119119
Metrics: &charts.ProxyMetrics{
120120
HostnameLabels: false,
121121
},
122+
Tracing: &charts.ProxyTracing{
123+
Enable: false,
124+
Protocol: "opentelemetry",
125+
TraceServiceName: "linkerd-proxy",
126+
Collector: &charts.ProxyTracingCollector{
127+
Endpoint: "",
128+
MeshIdentity: "",
129+
},
130+
},
122131
LivenessProbe: &charts.Probe{
123132
InitialDelaySeconds: 10,
124133
TimeoutSeconds: 1,

cli/cmd/testdata/install_controlplane_tracing_output.golden

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

cli/cmd/testdata/install_custom_domain.golden

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

cli/cmd/testdata/install_custom_registry.golden

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

cli/cmd/testdata/install_default.golden

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

0 commit comments

Comments
 (0)