Restrict controlPlaneTracing field only to control plane components (#5117)

* Restrict controlPlaneTracing field only to control plane components

Previously, `global.controlPlaneTracing` was not available during
injection and thus not affecting it.

This commit creates a new method which checks if controlPlaneTracing is
enabled and sets to the defaults if it is. This is done on the
duplicates thus preventing it from not being propagated into
`linkerd-config`

Signed-off-by: Tarun Pothulapati <tarunpothulapati@outlook.com>
This commit is contained in:
Tarun Pothulapati 2020-10-28 07:24:56 +05:30 committed by GitHub
parent 8c6a2c576c
commit 80794876e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 20 additions and 9 deletions

View File

@ -167,6 +167,7 @@ spec:
{{- $_ := set $tree.Values.global.proxy "resources" $r }} {{- $_ := set $tree.Values.global.proxy "resources" $r }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- include "partials.setControlPlaneTracing.proxy" $tree }}
- {{- include "partials.proxy" $tree | indent 8 | trimPrefix (repeat 7 " ") }} - {{- include "partials.proxy" $tree | indent 8 | trimPrefix (repeat 7 " ") }}
{{ if not .Values.global.cniEnabled -}} {{ if not .Values.global.cniEnabled -}}
initContainers: initContainers:

View File

@ -285,6 +285,7 @@ spec:
{{- $_ := set $tree.Values.global.proxy "resources" $r }} {{- $_ := set $tree.Values.global.proxy "resources" $r }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- include "partials.setControlPlaneTracing.proxy" $tree }}
- {{- include "partials.proxy" $tree | indent 8 | trimPrefix (repeat 7 " ") }} - {{- include "partials.proxy" $tree | indent 8 | trimPrefix (repeat 7 " ") }}
{{ if not .Values.global.cniEnabled -}} {{ if not .Values.global.cniEnabled -}}
initContainers: initContainers:

View File

@ -112,6 +112,7 @@ spec:
{{- $r := merge .Values.publicAPIProxyResources .Values.global.proxy.resources }} {{- $r := merge .Values.publicAPIProxyResources .Values.global.proxy.resources }}
{{- $_ := set $tree.Values.global.proxy "resources" $r }} {{- $_ := set $tree.Values.global.proxy "resources" $r }}
{{- end }} {{- end }}
{{- include "partials.setControlPlaneTracing.proxy" $tree }}
- {{- include "partials.proxy" $tree | indent 8 | trimPrefix (repeat 7 " ") }} - {{- include "partials.proxy" $tree | indent 8 | trimPrefix (repeat 7 " ") }}
{{ if not .Values.global.cniEnabled -}} {{ if not .Values.global.cniEnabled -}}
initContainers: initContainers:

View File

@ -129,6 +129,7 @@ spec:
{{- $r := merge .Values.destinationProxyResources .Values.global.proxy.resources }} {{- $r := merge .Values.destinationProxyResources .Values.global.proxy.resources }}
{{- $_ := set $tree.Values.global.proxy "resources" $r }} {{- $_ := set $tree.Values.global.proxy "resources" $r }}
{{- end }} {{- end }}
{{- include "partials.setControlPlaneTracing.proxy" $tree }}
- {{- include "partials.proxy" $tree | indent 8 | trimPrefix (repeat 7 " ") }} - {{- include "partials.proxy" $tree | indent 8 | trimPrefix (repeat 7 " ") }}
{{ if not .Values.global.cniEnabled -}} {{ if not .Values.global.cniEnabled -}}
initContainers: initContainers:

View File

@ -152,6 +152,7 @@ spec:
{{- $r := merge .Values.identityProxyResources .Values.global.proxy.resources }} {{- $r := merge .Values.identityProxyResources .Values.global.proxy.resources }}
{{- $_ := set $tree.Values.global.proxy "resources" $r }} {{- $_ := set $tree.Values.global.proxy "resources" $r }}
{{- end }} {{- end }}
{{- include "partials.setControlPlaneTracing.proxy" $tree }}
- {{- include "partials.proxy" $tree | indent 8 | trimPrefix (repeat 7 " ") }} - {{- include "partials.proxy" $tree | indent 8 | trimPrefix (repeat 7 " ") }}
{{ if not .Values.global.cniEnabled -}} {{ if not .Values.global.cniEnabled -}}
initContainers: initContainers:

View File

@ -91,6 +91,7 @@ spec:
{{- $r := merge .Values.proxyInjectorProxyResources .Values.global.proxy.resources }} {{- $r := merge .Values.proxyInjectorProxyResources .Values.global.proxy.resources }}
{{- $_ := set $tree.Values.global.proxy "resources" $r }} {{- $_ := set $tree.Values.global.proxy "resources" $r }}
{{- end }} {{- end }}
{{- include "partials.setControlPlaneTracing.proxy" $tree }}
- {{- include "partials.proxy" $tree | indent 8 | trimPrefix (repeat 7 " ") }} - {{- include "partials.proxy" $tree | indent 8 | trimPrefix (repeat 7 " ") }}
{{ if not .Values.global.cniEnabled -}} {{ if not .Values.global.cniEnabled -}}
initContainers: initContainers:

View File

@ -108,6 +108,7 @@ spec:
{{- $r := merge .Values.spValidatorProxyResources .Values.global.proxy.resources }} {{- $r := merge .Values.spValidatorProxyResources .Values.global.proxy.resources }}
{{- $_ := set $tree.Values.global.proxy "resources" $r }} {{- $_ := set $tree.Values.global.proxy "resources" $r }}
{{- end }} {{- end }}
{{- include "partials.setControlPlaneTracing.proxy" $tree }}
- {{- include "partials.proxy" $tree | indent 8 | trimPrefix (repeat 7 " ") }} - {{- include "partials.proxy" $tree | indent 8 | trimPrefix (repeat 7 " ") }}
{{ if not .Values.global.cniEnabled -}} {{ if not .Values.global.cniEnabled -}}
initContainers: initContainers:

View File

@ -118,6 +118,7 @@ spec:
{{- $r := merge .Values.tapProxyResources .Values.global.proxy.resources }} {{- $r := merge .Values.tapProxyResources .Values.global.proxy.resources }}
{{- $_ := set $tree.Values.global.proxy "resources" $r }} {{- $_ := set $tree.Values.global.proxy "resources" $r }}
{{- end }} {{- end }}
{{- include "partials.setControlPlaneTracing.proxy" $tree }}
- {{- include "partials.proxy" $tree | indent 8 | trimPrefix (repeat 7 " ") }} - {{- include "partials.proxy" $tree | indent 8 | trimPrefix (repeat 7 " ") }}
{{ if not .Values.global.cniEnabled -}} {{ if not .Values.global.cniEnabled -}}
initContainers: initContainers:

View File

@ -115,6 +115,7 @@ spec:
{{- $r := merge .Values.webProxyResources .Values.global.proxy.resources }} {{- $r := merge .Values.webProxyResources .Values.global.proxy.resources }}
{{- $_ := set $tree.Values.global.proxy "resources" $r }} {{- $_ := set $tree.Values.global.proxy "resources" $r }}
{{- end }} {{- end }}
{{- include "partials.setControlPlaneTracing.proxy" $tree }}
- {{- include "partials.proxy" $tree | indent 8 | trimPrefix (repeat 7 " ") }} - {{- include "partials.proxy" $tree | indent 8 | trimPrefix (repeat 7 " ") }}
{{ if not .Values.global.cniEnabled -}} {{ if not .Values.global.cniEnabled -}}
initContainers: initContainers:

View File

@ -43,7 +43,7 @@ env:
value: 10000ms value: 10000ms
- name: LINKERD2_PROXY_OUTBOUND_CONNECT_KEEPALIVE - name: LINKERD2_PROXY_OUTBOUND_CONNECT_KEEPALIVE
value: 10000ms value: 10000ms
{{ if or (.Values.global.proxy.trace.collectorSvcAddr) (.Values.global.controlPlaneTracing) -}} {{ if .Values.global.proxy.trace.collectorSvcAddr -}}
- name: LINKERD2_PROXY_TRACE_ATTRIBUTES_PATH - name: LINKERD2_PROXY_TRACE_ATTRIBUTES_PATH
value: /var/run/linkerd/podinfo/labels value: /var/run/linkerd/podinfo/labels
{{ end -}} {{ end -}}
@ -98,12 +98,7 @@ env:
- name: LINKERD2_PROXY_TAP_SVC_NAME - name: LINKERD2_PROXY_TAP_SVC_NAME
value: linkerd-tap.$(_l5d_ns).serviceaccount.identity.$(_l5d_ns).$(_l5d_trustdomain) value: linkerd-tap.$(_l5d_ns).serviceaccount.identity.$(_l5d_ns).$(_l5d_trustdomain)
{{ end -}} {{ end -}}
{{ if .Values.global.controlPlaneTracing -}} {{ if .Values.global.proxy.trace.collectorSvcAddr -}}
- name: LINKERD2_PROXY_TRACE_COLLECTOR_SVC_ADDR
value: linkerd-collector.{{.Values.global.namespace}}.svc.{{.Values.global.clusterDomain}}:55678
- name: LINKERD2_PROXY_TRACE_COLLECTOR_SVC_NAME
value: linkerd-collector.{{.Values.global.namespace}}.serviceaccount.identity.$(_l5d_ns).$(_l5d_trustdomain)
{{ else if .Values.global.proxy.trace.collectorSvcAddr -}}
- name: LINKERD2_PROXY_TRACE_COLLECTOR_SVC_ADDR - name: LINKERD2_PROXY_TRACE_COLLECTOR_SVC_ADDR
value: {{ .Values.global.proxy.trace.collectorSvcAddr }} value: {{ .Values.global.proxy.trace.collectorSvcAddr }}
- name: LINKERD2_PROXY_TRACE_COLLECTOR_SVC_NAME - name: LINKERD2_PROXY_TRACE_COLLECTOR_SVC_NAME
@ -147,9 +142,9 @@ lifecycle:
- -c - -c
- sleep {{.Values.global.proxy.waitBeforeExitSeconds}} - sleep {{.Values.global.proxy.waitBeforeExitSeconds}}
{{- end }} {{- end }}
{{- if or (.Values.global.proxy.trace.collectorSvcAddr) (.Values.global.controlPlaneTracing) (not .Values.global.proxy.disableIdentity) (.Values.global.proxy.saMountPath) }} {{- if or (.Values.global.proxy.trace.collectorSvcAddr) (not .Values.global.proxy.disableIdentity) (.Values.global.proxy.saMountPath) }}
volumeMounts: volumeMounts:
{{- if or (.Values.global.proxy.trace.collectorSvcAddr) (.Values.global.controlPlaneTracing) }} {{- if .Values.global.proxy.trace.collectorSvcAddr }}
- mountPath: var/run/linkerd/podinfo - mountPath: var/run/linkerd/podinfo
name: podinfo name: podinfo
{{- end -}} {{- end -}}

View File

@ -3,3 +3,10 @@
- -trace-collector=linkerd-collector.{{.Values.global.namespace}}.svc.{{.Values.global.clusterDomain}}:55678 - -trace-collector=linkerd-collector.{{.Values.global.namespace}}.svc.{{.Values.global.clusterDomain}}:55678
{{ end -}} {{ end -}}
{{- end }} {{- end }}
{{ define "partials.setControlPlaneTracing.proxy" -}}
{{ if .Values.global.controlPlaneTracing -}}
{{ $_ := set .Values.global.proxy.trace "collectorSvcAddr" (printf "linkerd-collector.%s.svc.%s:55678" .Values.global.namespace .Values.global.clusterDomain) -}}
{{ $_ := set .Values.global.proxy.trace "collectorSvcAccount" (printf "linkerd-collector.%s" .Values.global.namespace) -}}
{{ end -}}
{{- end }}