Skip to content

Commit 4364e08

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 520435e commit 4364e08

29 files changed

+320
-41
lines changed

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

Lines changed: 3 additions & 0 deletions
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.enable -}}
451+
- {{- include "partials.proxy.volumes.podinfo" . | indent 8 | trimPrefix (repeat 7 " ") }}
452+
{{ end }}

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

Lines changed: 4 additions & 1 deletion
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.enable -}}
278+
- {{- include "partials.proxy.volumes.podinfo" . | indent 8 | trimPrefix (repeat 7 " ") }}
279+
{{ end }}
277280
{{end -}}

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

Lines changed: 3 additions & 0 deletions
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.enable -}}
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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,18 @@ 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+
traceServiceName: linkerd-proxy
292+
collector:
293+
# -- The collector endpoint to send traces to.
294+
endpoint: ""
295+
# -- The identity of the collector in the linkerd mesh. If the collector
296+
# is unmeshed, this should remain unset.
297+
meshIdentity:
298+
serviceAccountName: ""
287299
inbound:
288300
server:
289301
http2:

charts/partials/templates/_proxy.tpl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,24 @@ env:
148148
value: 30s
149149
- name: LINKERD2_PROXY_OUTBOUND_METRICS_HOSTNAME_LABELS
150150
value: {{ .Values.proxy.metrics.hostnameLabels | quote }}
151+
{{- if .Values.proxy.tracing.enable -}}
152+
- name: LINKERD2_PROXY_TRACE_ATTRIBUTES_PATH
153+
value: /var/run/linkerd/podinfo/labels
154+
- name: LINKERD2_PROXY_TRACE_PROTOCOL
155+
value: {{ default "opentelemetry" .Values.proxy.tracing.protocol }}
156+
- name: LINKERD2_PROXY_TRACE_SERVICE_NAME
157+
value: {{ .Values.proxy.tracing.traceServiceName }}
158+
- name: LINKERD2_PROXY_TRACE_COLLECTOR_SVC_ADDR
159+
value: {{ .Values.proxy.tracing.collector.endpoint }}
160+
{{ if .Values.proxy.tracing.collector.meshIdentity.serviceAccountName -}}
161+
- name: LINKERD2_PROXY_TRACE_COLLECTOR_SVC_NAME
162+
value: {{ .Values.proxy.tracing.collector.meshIdentity.serviceAccountName }}.serviceaccount.identity.{{.Release.Namespace}}.{{ .Values.clusterDomain }}
163+
{{ end -}}
164+
- name: LINKERD2_PROXY_TRACE_EXTRA_ATTRIBUTES
165+
value: |
166+
k8s.pod.uid=$(_pod_uid)
167+
k8s.container.name=$(_pod_containerName)
168+
{{ end -}}
151169
{{- /* Configure inbound and outbound parameters, e.g. for HTTP/2 servers. */}}
152170
{{ range $proxyK, $proxyV := (dict "inbound" .Values.proxy.inbound "outbound" .Values.proxy.outbound) -}}
153171
{{ range $scopeK, $scopeV := $proxyV -}}
@@ -288,6 +306,10 @@ lifecycle:
288306
volumeMounts:
289307
- mountPath: /var/run/linkerd/identity/end-entity
290308
name: linkerd-identity-end-entity
309+
{{ if .Values.proxy.tracing.enable }}
310+
- mountPath: /var/run/linkerd/podinfo
311+
name: linkerd-podinfo
312+
{{- end }}
291313
{{- if .Values.identity.serviceAccountTokenProjection }}
292314
- mountPath: /var/run/secrets/tokens
293315
name: linkerd-identity-token

charts/partials/templates/_volumes.tpl

Lines changed: 10 additions & 1 deletion
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

Lines changed: 19 additions & 0 deletions
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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,16 @@ func TestRender(t *testing.T) {
119119
Metrics: &charts.ProxyMetrics{
120120
HostnameLabels: false,
121121
},
122+
Tracing: &charts.ProxyTracing{
123+
Enable: false,
124+
TraceServiceName: "linkerd-proxy",
125+
Collector: &charts.ProxyTracingCollector{
126+
Endpoint: "",
127+
MeshIdentity: &charts.ProxyTracingCollectorIdentity{
128+
ServiceAccountName: "",
129+
},
130+
},
131+
},
122132
LivenessProbe: &charts.Probe{
123133
InitialDelaySeconds: 10,
124134
TimeoutSeconds: 1,

cli/cmd/testdata/install_controlplane_tracing_output.golden

Lines changed: 12 additions & 3 deletions
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

Lines changed: 12 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)