Repository: linkerd/linkerd2
Pull request #5142 (2020-10-27 13:01:15)

docs: Update external prom and grafana readme
Update `Values.yaml` to make it more clear about reverse proxy
configuration with external grafana instances.

Also, adds `global.prometheusUrl` and `global.grafanaUrl` into charts
`README`

Signed-off-by: Tarun Pothulapati <tarunpothulapati@outlook.com>



Patch:
diff --git a/CHANGES.md b/CHANGES.md
index d4a0dfe91..72b59228b 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,9 +1,22 @@
 # Changes
 
+## edge-20.10.6
+
+This edge supersedes edge-20.10.5 as a release candidate for stable-2.9.0. It
+adds a new `linkerd.io/inject: ingress` annotation to support service profiles
+and enable per-route metrics and traffic splits for HTTP ingress controllers
+
+* Added a new `linkerd.io/inject: ingress` annotation to configure the
+  proxy to support service profiles and enable per-route metrics and traffic
+  splits for HTTP ingress controllers
+* Reduced performance impact of logging in the proxy, especially when the
+  `debug` or `trace` log levels are disabled
+* Fixed spurious warnings logged by the `linkerd profile` CLI command
+
 ## edge-20.10.5
 
 This edge supersedes edge-20.10.4 as a release candidate for stable-2.9.0. It
-adds a fix for updating the destination service when ther are no endpoints
+adds a fix for updating the destination service when there are no endpoints
 
 * Added a fix to clear the EndpointTranslator state when it gets a
   `NoEndpoints` message. This ensures that the clients get the correct set of
diff --git a/charts/add-ons/grafana/templates/grafana.yaml b/charts/add-ons/grafana/templates/grafana.yaml
index f7b7b773a..8034e7ee6 100644
--- a/charts/add-ons/grafana/templates/grafana.yaml
+++ b/charts/add-ons/grafana/templates/grafana.yaml
@@ -167,6 +167,7 @@ spec:
       {{- $_ := set $tree.Values.global.proxy "resources" $r }}
       {{- end }}
       {{- end }}
+      {{- include "partials.setControlPlaneTracing.proxy" $tree }}
       - {{- include "partials.proxy" $tree | indent 8 | trimPrefix (repeat 7 " ") }}
       {{ if not .Values.global.cniEnabled -}}
       initContainers:
diff --git a/charts/add-ons/prometheus/templates/prometheus.yaml b/charts/add-ons/prometheus/templates/prometheus.yaml
index f3ea80245..44475f1f8 100644
--- a/charts/add-ons/prometheus/templates/prometheus.yaml
+++ b/charts/add-ons/prometheus/templates/prometheus.yaml
@@ -285,6 +285,7 @@ spec:
       {{- $_ := set $tree.Values.global.proxy "resources" $r }}
       {{- end }}
       {{- end }}
+      {{- include "partials.setControlPlaneTracing.proxy" $tree }}
       - {{- include "partials.proxy" $tree | indent 8 | trimPrefix (repeat 7 " ") }}
       {{ if not .Values.global.cniEnabled -}}
       initContainers:
diff --git a/charts/linkerd2/README.md b/charts/linkerd2/README.md
index 6044554c7..2e2e8f145 100644
--- a/charts/linkerd2/README.md
+++ b/charts/linkerd2/README.md
@@ -104,6 +104,7 @@ their default values.
 | `global.controllerImageVersion`             | Tag for the controller container docker image                                                                                                                                         | latest version                       |
 | `global.controllerLogLevel`                 | Log level for the control plane components                                                                                                                                            | `info`                               |
 | `global.controllerNamespaceLabel`           | Control plane label. Do not edit                                                                                                                                                      | `linkerd.io/control-plane-ns`        |
+| `global.grafanaUrl`                          | URL of external grafana instance configured with reverse proxy, used by the dashboard                                                                                                                                      |                                 |
 | `global.podLabels`                          | Additional labels to add to all pods                                                                                                                                                  | `{}`                                 |
 | `global.podAnnotations`                     | Additional annotations to add to all pods                                                                                                                                             | `{}`                                 |
 | `global.createdByAnnotation`                | Annotation label for the proxy create. Do not edit.                                                                                                                                   | `linkerd.io/created-by`              |
@@ -113,6 +114,7 @@ their default values.
 | `global.linkerdNamespaceLabel`              | Control plane label. Do not edit                                                                                                                                                      | `linkerd.io/is-control-plane` |
 | `global.linkerdVersion`                     | Control plane version                                                                                                                                                                 | latest version                       |
 | `global.namespace`                          | Control plane namespace                                                                                                                                                               | `linkerd`                            |
+| `global.prometheusUrl`     | URL of external prometheus instance to perform queries, used by the `public-api`                                                                                                                    |                               |
 | `global.proxy.enableExternalProfiles`       | Enable service profiles for non-Kubernetes services                                                                                                                                   | `false`                              |
 | `global.proxy.image.name`                   | Docker image for the proxy                                                                                                                                                            | `ghcr.io/linkerd/proxy`            |
 | `global.proxy.image.pullPolicy`             | Pull policy for the proxy container Docker image                                                                                                                                      | `IfNotPresent`                       |
diff --git a/charts/linkerd2/templates/controller.yaml b/charts/linkerd2/templates/controller.yaml
index 83786b16d..d7a111a57 100644
--- a/charts/linkerd2/templates/controller.yaml
+++ b/charts/linkerd2/templates/controller.yaml
@@ -112,6 +112,7 @@ spec:
       {{- $r := merge .Values.publicAPIProxyResources .Values.global.proxy.resources }}
       {{- $_ := set $tree.Values.global.proxy "resources" $r }}
       {{- end }}
+      {{- include "partials.setControlPlaneTracing.proxy" $tree }}
       - {{- include "partials.proxy" $tree | indent 8 | trimPrefix (repeat 7 " ") }}
       {{ if not .Values.global.cniEnabled -}}
       initContainers:
diff --git a/charts/linkerd2/templates/destination.yaml b/charts/linkerd2/templates/destination.yaml
index c478b3bf5..6b853f5ae 100644
--- a/charts/linkerd2/templates/destination.yaml
+++ b/charts/linkerd2/templates/destination.yaml
@@ -129,6 +129,7 @@ spec:
       {{- $r := merge .Values.destinationProxyResources .Values.global.proxy.resources }}
       {{- $_ := set $tree.Values.global.proxy "resources" $r }}
       {{- end }}
+            {{- include "partials.setControlPlaneTracing.proxy" $tree }}
       - {{- include "partials.proxy" $tree | indent 8 | trimPrefix (repeat 7 " ") }}
       {{ if not .Values.global.cniEnabled -}}
       initContainers:
diff --git a/charts/linkerd2/templates/identity.yaml b/charts/linkerd2/templates/identity.yaml
index 99e325fc1..14450c806 100644
--- a/charts/linkerd2/templates/identity.yaml
+++ b/charts/linkerd2/templates/identity.yaml
@@ -152,6 +152,7 @@ spec:
       {{- $r := merge .Values.identityProxyResources .Values.global.proxy.resources }}
       {{- $_ := set $tree.Values.global.proxy "resources" $r }}
       {{- end }}
+      {{- include "partials.setControlPlaneTracing.proxy" $tree }}
       - {{- include "partials.proxy" $tree | indent 8 | trimPrefix (repeat 7 " ") }}
       {{ if not .Values.global.cniEnabled -}}
       initContainers:
diff --git a/charts/linkerd2/templates/proxy-injector.yaml b/charts/linkerd2/templates/proxy-injector.yaml
index b17de25b1..7b2f68ef8 100644
--- a/charts/linkerd2/templates/proxy-injector.yaml
+++ b/charts/linkerd2/templates/proxy-injector.yaml
@@ -91,6 +91,7 @@ spec:
       {{- $r := merge .Values.proxyInjectorProxyResources .Values.global.proxy.resources }}
       {{- $_ := set $tree.Values.global.proxy "resources" $r }}
       {{- end }}
+      {{- include "partials.setControlPlaneTracing.proxy" $tree }}
       - {{- include "partials.proxy" $tree | indent 8 | trimPrefix (repeat 7 " ") }}
       {{ if not .Values.global.cniEnabled -}}
       initContainers:
diff --git a/charts/linkerd2/templates/sp-validator.yaml b/charts/linkerd2/templates/sp-validator.yaml
index 8e65393a1..58e94b53a 100644
--- a/charts/linkerd2/templates/sp-validator.yaml
+++ b/charts/linkerd2/templates/sp-validator.yaml
@@ -108,6 +108,7 @@ spec:
       {{- $r := merge .Values.spValidatorProxyResources .Values.global.proxy.resources }}
       {{- $_ := set $tree.Values.global.proxy "resources" $r }}
       {{- end }}
+      {{- include "partials.setControlPlaneTracing.proxy" $tree }}
       - {{- include "partials.proxy" $tree | indent 8 | trimPrefix (repeat 7 " ") }}
       {{ if not .Values.global.cniEnabled -}}
       initContainers:
diff --git a/charts/linkerd2/templates/tap.yaml b/charts/linkerd2/templates/tap.yaml
index 4f7fe8a69..a6754f18e 100644
--- a/charts/linkerd2/templates/tap.yaml
+++ b/charts/linkerd2/templates/tap.yaml
@@ -118,6 +118,7 @@ spec:
       {{- $r := merge .Values.tapProxyResources .Values.global.proxy.resources }}
       {{- $_ := set $tree.Values.global.proxy "resources" $r }}
       {{- end }}
+      {{- include "partials.setControlPlaneTracing.proxy" $tree }}
       - {{- include "partials.proxy" $tree | indent 8 | trimPrefix (repeat 7 " ") }}
       {{ if not .Values.global.cniEnabled -}}
       initContainers:
diff --git a/charts/linkerd2/templates/web.yaml b/charts/linkerd2/templates/web.yaml
index 6c4c87bba..eb5be68af 100644
--- a/charts/linkerd2/templates/web.yaml
+++ b/charts/linkerd2/templates/web.yaml
@@ -115,6 +115,7 @@ spec:
       {{- $r := merge .Values.webProxyResources .Values.global.proxy.resources }}
       {{- $_ := set $tree.Values.global.proxy "resources" $r }}
       {{- end }}
+      {{- include "partials.setControlPlaneTracing.proxy" $tree }}
       - {{- include "partials.proxy" $tree | indent 8 | trimPrefix (repeat 7 " ") }}
       {{ if not .Values.global.cniEnabled -}}
       initContainers:
diff --git a/charts/linkerd2/values.yaml b/charts/linkerd2/values.yaml
index 65fe05a77..7eeb7bb7a 100644
--- a/charts/linkerd2/values.yaml
+++ b/charts/linkerd2/values.yaml
@@ -41,7 +41,7 @@ global:
 
   # url of existing prometheus
   prometheusUrl: ""
-  # url of external grafana instance.
+  # url of external grafana instance with reverse proxy configured
   grafanaUrl: ""
 
   # Additional annotations to add to all pods
diff --git a/charts/partials/templates/_proxy.tpl b/charts/partials/templates/_proxy.tpl
index 3300b4c64..e67a3547f 100644
--- a/charts/partials/templates/_proxy.tpl
+++ b/charts/partials/templates/_proxy.tpl
@@ -43,7 +43,7 @@ env:
   value: 10000ms
 - name: LINKERD2_PROXY_OUTBOUND_CONNECT_KEEPALIVE
   value: 10000ms
-{{ if or (.Values.global.proxy.trace.collectorSvcAddr) (.Values.global.controlPlaneTracing) -}}
+{{ if .Values.global.proxy.trace.collectorSvcAddr -}}
 - name: LINKERD2_PROXY_TRACE_ATTRIBUTES_PATH
   value: /var/run/linkerd/podinfo/labels
 {{ end -}}
@@ -98,12 +98,7 @@ env:
 - name: LINKERD2_PROXY_TAP_SVC_NAME
   value: linkerd-tap.$(_l5d_ns).serviceaccount.identity.$(_l5d_ns).$(_l5d_trustdomain)
 {{ end -}}
-{{ if .Values.global.controlPlaneTracing -}}
-- 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 -}}
+{{ if .Values.global.proxy.trace.collectorSvcAddr -}}
 - name: LINKERD2_PROXY_TRACE_COLLECTOR_SVC_ADDR
   value: {{ .Values.global.proxy.trace.collectorSvcAddr }}
 - name: LINKERD2_PROXY_TRACE_COLLECTOR_SVC_NAME
@@ -147,9 +142,9 @@ lifecycle:
         - -c
         - sleep {{.Values.global.proxy.waitBeforeExitSeconds}}
 {{- 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:
-{{- if or (.Values.global.proxy.trace.collectorSvcAddr) (.Values.global.controlPlaneTracing) }}
+{{- if .Values.global.proxy.trace.collectorSvcAddr }}
 - mountPath: var/run/linkerd/podinfo
   name: podinfo
 {{- end -}}
diff --git a/charts/partials/templates/_trace.tpl b/charts/partials/templates/_trace.tpl
index 8e60ff886..8bf6295d7 100644
--- a/charts/partials/templates/_trace.tpl
+++ b/charts/partials/templates/_trace.tpl
@@ -3,3 +3,10 @@
 - -trace-collector=linkerd-collector.{{.Values.global.namespace}}.svc.{{.Values.global.clusterDomain}}:55678
 {{ 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 }}
diff --git a/cli/cmd/profile.go b/cli/cmd/profile.go
index 2e58db4c1..12e3241c8 100644
--- a/cli/cmd/profile.go
+++ b/cli/cmd/profile.go
@@ -120,7 +120,7 @@ func newCmdProfile() *cobra.Command {
 			} else if options.openAPI != "" {
 				return profiles.RenderOpenAPI(options.openAPI, options.namespace, options.name, clusterDomain, os.Stdout)
 			} else if options.tap != "" {
-				return profiles.RenderTapOutputProfile(k8sAPI, options.tap, options.namespace, options.name, clusterDomain, options.tapDuration, int(options.tapRouteLimit), os.Stdout)
+				return profiles.RenderTapOutputProfile(cmd.Context(), k8sAPI, options.tap, options.namespace, options.name, clusterDomain, options.tapDuration, int(options.tapRouteLimit), os.Stdout)
 			} else if options.proto != "" {
 				return profiles.RenderProto(options.proto, options.namespace, options.name, clusterDomain, os.Stdout)
 			}
diff --git a/cli/cmd/tap.go b/cli/cmd/tap.go
index fc28b8ea7..0195a03c1 100644
--- a/cli/cmd/tap.go
+++ b/cli/cmd/tap.go
@@ -2,6 +2,7 @@ package cmd
 
 import (
 	"bufio"
+	"context"
 	"encoding/json"
 	"fmt"
 	"io"
@@ -199,7 +200,7 @@ func newCmdTap() *cobra.Command {
 				return err
 			}
 
-			return requestTapByResourceFromAPI(os.Stdout, k8sAPI, req, options)
+			return requestTapByResourceFromAPI(cmd.Context(), os.Stdout, k8sAPI, req, options)
 		},
 	}
 
@@ -227,8 +228,8 @@ func newCmdTap() *cobra.Command {
 	return cmd
 }
 
-func requestTapByResourceFromAPI(w io.Writer, k8sAPI *k8s.KubernetesAPI, req *pb.TapByResourceRequest, options *tapOptions) error {
-	reader, body, err := tap.Reader(k8sAPI, req, 0)
+func requestTapByResourceFromAPI(ctx context.Context, w io.Writer, k8sAPI *k8s.KubernetesAPI, req *pb.TapByResourceRequest, options *tapOptions) error {
+	reader, body, err := tap.Reader(ctx, k8sAPI, req)
 	if err != nil {
 		return err
 	}
diff --git a/cli/cmd/top.go b/cli/cmd/top.go
index 2378caec5..75b7e2345 100644
--- a/cli/cmd/top.go
+++ b/cli/cmd/top.go
@@ -2,6 +2,7 @@ package cmd
 
 import (
 	"bufio"
+	"context"
 	"fmt"
 	"io"
 	"sort"
@@ -355,7 +356,7 @@ func newCmdTop() *cobra.Command {
 				return err
 			}
 
-			return getTrafficByResourceFromAPI(k8sAPI, req, table)
+			return getTrafficByResourceFromAPI(cmd.Context(), k8sAPI, req, table)
 		},
 	}
 
@@ -382,8 +383,8 @@ func newCmdTop() *cobra.Command {
 	return cmd
 }
 
-func getTrafficByResourceFromAPI(k8sAPI *k8s.KubernetesAPI, req *pb.TapByResourceRequest, table *topTable) error {
-	reader, body, err := tap.Reader(k8sAPI, req, 0)
+func getTrafficByResourceFromAPI(ctx context.Context, k8sAPI *k8s.KubernetesAPI, req *pb.TapByResourceRequest, table *topTable) error {
+	reader, body, err := tap.Reader(ctx, k8sAPI, req)
 	if err != nil {
 		return err
 	}
diff --git a/pkg/profiles/tap.go b/pkg/profiles/tap.go
index bddf60c6f..0d43d611e 100644
--- a/pkg/profiles/tap.go
+++ b/pkg/profiles/tap.go
@@ -2,6 +2,7 @@ package profiles
 
 import (
 	"bufio"
+	"context"
 	"fmt"
 	"io"
 	"os"
@@ -23,7 +24,7 @@ import (
 // RenderTapOutputProfile performs a tap on the desired resource and generates
 // a service profile with routes pre-populated from the tap data
 // Only inbound tap traffic is considered.
-func RenderTapOutputProfile(k8sAPI *k8s.KubernetesAPI, tapResource, namespace, name, clusterDomain string, tapDuration time.Duration, routeLimit int, w io.Writer) error {
+func RenderTapOutputProfile(ctx context.Context, k8sAPI *k8s.KubernetesAPI, tapResource, namespace, name, clusterDomain string, tapDuration time.Duration, routeLimit int, w io.Writer) error {
 	requestParams := util.TapRequestParams{
 		Resource:  tapResource,
 		Namespace: namespace,
@@ -35,7 +36,7 @@ func RenderTapOutputProfile(k8sAPI *k8s.KubernetesAPI, tapResource, namespace, n
 		return err
 	}
 
-	profile, err := tapToServiceProfile(k8sAPI, req, namespace, name, clusterDomain, tapDuration, routeLimit)
+	profile, err := tapToServiceProfile(ctx, k8sAPI, req, namespace, name, clusterDomain, tapDuration, routeLimit)
 	if err != nil {
 		return err
 	}
@@ -48,7 +49,7 @@ func RenderTapOutputProfile(k8sAPI *k8s.KubernetesAPI, tapResource, namespace, n
 	return nil
 }
 
-func tapToServiceProfile(k8sAPI *k8s.KubernetesAPI, tapReq *pb.TapByResourceRequest, namespace, name, clusterDomain string, tapDuration time.Duration, routeLimit int) (sp.ServiceProfile, error) {
+func tapToServiceProfile(ctx context.Context, k8sAPI *k8s.KubernetesAPI, tapReq *pb.TapByResourceRequest, namespace, name, clusterDomain string, tapDuration time.Duration, routeLimit int) (sp.ServiceProfile, error) {
 	profile := sp.ServiceProfile{
 		ObjectMeta: metav1.ObjectMeta{
 			Name:      fmt.Sprintf("%s.%s.svc.%s", name, namespace, clusterDomain),
@@ -57,7 +58,9 @@ func tapToServiceProfile(k8sAPI *k8s.KubernetesAPI, tapReq *pb.TapByResourceRequ
 		TypeMeta: serviceProfileMeta,
 	}
 
-	reader, body, err := tap.Reader(k8sAPI, tapReq, tapDuration)
+	ctxWithTime, cancel := context.WithTimeout(ctx, tapDuration)
+	defer cancel()
+	reader, body, err := tap.Reader(ctxWithTime, k8sAPI, tapReq)
 	if err != nil {
 		return profile, err
 	}
@@ -81,7 +84,8 @@ func routeSpecFromTap(tapByteStream *bufio.Reader, routeLimit int) []*sp.RouteSp
 		if err != nil {
 			// expected errors when hitting the tapDuration deadline
 			if err != io.EOF &&
-				!strings.HasSuffix(err.Error(), "(Client.Timeout exceeded while reading body)") &&
+				!strings.HasSuffix(err.Error(), "(Client.Timeout or context cancellation while reading body)") &&
+				!strings.HasSuffix(err.Error(), "context deadline exceeded") &&
 				!strings.HasSuffix(err.Error(), "http2: response body closed") {
 				fmt.Fprintln(os.Stderr, err)
 			}
diff --git a/pkg/tap/tap.go b/pkg/tap/tap.go
index 80d6b903b..1c1a78617 100644
--- a/pkg/tap/tap.go
+++ b/pkg/tap/tap.go
@@ -3,11 +3,11 @@ package tap
 import (
 	"bufio"
 	"bytes"
+	"context"
 	"fmt"
 	"io"
 	"net/http"
 	"net/url"
-	"time"
 
 	"github.com/golang/protobuf/proto"
 	pb "github.com/linkerd/linkerd2/controller/gen/public"
@@ -22,12 +22,11 @@ const TapRbacURL = "https://linkerd.io/tap-rbac"
 
 // Reader initiates a TapByResourceRequest and returns a buffered Reader.
 // It is the caller's responsibility to call Close() on the io.ReadCloser.
-func Reader(k8sAPI *k8s.KubernetesAPI, req *pb.TapByResourceRequest, timeout time.Duration) (*bufio.Reader, io.ReadCloser, error) {
+func Reader(ctx context.Context, k8sAPI *k8s.KubernetesAPI, req *pb.TapByResourceRequest) (*bufio.Reader, io.ReadCloser, error) {
 	client, err := k8sAPI.NewClient()
 	if err != nil {
 		return nil, nil, err
 	}
-	client.Timeout = timeout
 
 	reqBytes, err := proto.Marshal(req)
 	if err != nil {
@@ -49,7 +48,7 @@ func Reader(k8sAPI *k8s.KubernetesAPI, req *pb.TapByResourceRequest, timeout tim
 		return nil, nil, err
 	}
 
-	httpRsp, err := client.Do(httpReq)
+	httpRsp, err := client.Do(httpReq.WithContext(ctx))
 	if err != nil {
 		log.Debugf("Error invoking [%s]: %v", url, err)
 		return nil, nil, err
diff --git a/web/srv/api_handlers.go b/web/srv/api_handlers.go
index 53d1d002d..13be10b44 100644
--- a/web/srv/api_handlers.go
+++ b/web/srv/api_handlers.go
@@ -269,7 +269,7 @@ func (h *handler) handleAPITap(w http.ResponseWriter, req *http.Request, p httpr
 	}
 
 	go func() {
-		reader, body, err := tap.Reader(h.k8sAPI, tapReq, 0)
+		reader, body, err := tap.Reader(req.Context(), h.k8sAPI, tapReq)
 		if err != nil {
 			// If there was a [403] error when initiating a tap, close the
 			// socket with `ClosePolicyViolation` status code so that the error


Test patch:
diff --git a/cli/cmd/tap_test.go b/cli/cmd/tap_test.go
index fbc0fc6fe..ada59bb7b 100644
--- a/cli/cmd/tap_test.go
+++ b/cli/cmd/tap_test.go
@@ -2,6 +2,7 @@ package cmd
 
 import (
 	"bytes"
+	"context"
 	"io/ioutil"
 	"net/http"
 	"net/http/httptest"
@@ -131,7 +132,7 @@ func busyTest(t *testing.T, output string) {
 	options.output = output
 
 	writer := bytes.NewBufferString("")
-	err = requestTapByResourceFromAPI(writer, kubeAPI, req, options)
+	err = requestTapByResourceFromAPI(context.Background(), writer, kubeAPI, req, options)
 	if err != nil {
 		t.Fatalf("Unexpected error: %v", err)
 	}
@@ -158,6 +159,8 @@ func busyTest(t *testing.T, output string) {
 }
 
 func TestRequestTapByResourceFromAPI(t *testing.T) {
+
+	ctx := context.Background()
 	t.Run("Should render busy response if everything went well", func(t *testing.T) {
 		busyTest(t, "")
 	})
@@ -197,7 +200,7 @@ func TestRequestTapByResourceFromAPI(t *testing.T) {
 
 		options := newTapOptions()
 		writer := bytes.NewBufferString("")
-		err = requestTapByResourceFromAPI(writer, kubeAPI, req, options)
+		err = requestTapByResourceFromAPI(ctx, writer, kubeAPI, req, options)
 		if err != nil {
 			t.Fatalf("Unexpected error: %v", err)
 		}
@@ -236,7 +239,7 @@ func TestRequestTapByResourceFromAPI(t *testing.T) {
 
 		options := newTapOptions()
 		writer := bytes.NewBufferString("")
-		err = requestTapByResourceFromAPI(writer, kubeAPI, req, options)
+		err = requestTapByResourceFromAPI(ctx, writer, kubeAPI, req, options)
 		if err == nil {
 			t.Fatalf("Expecting error, got nothing but output [%s]", writer.String())
 		}
diff --git a/pkg/profiles/tap_test.go b/pkg/profiles/tap_test.go
index 742f91664..4bb286ff0 100644
--- a/pkg/profiles/tap_test.go
+++ b/pkg/profiles/tap_test.go
@@ -1,6 +1,7 @@
 package profiles
 
 import (
+	"context"
 	"net/http"
 	"net/http/httptest"
 	"testing"
@@ -119,7 +120,7 @@ func TestTapToServiceProfile(t *testing.T) {
 		},
 	}
 
-	actualServiceProfile, err := tapToServiceProfile(kubeAPI, tapReq, namespace, name, clusterDomain, tapDuration, routeLimit)
+	actualServiceProfile, err := tapToServiceProfile(context.Background(), kubeAPI, tapReq, namespace, name, clusterDomain, tapDuration, routeLimit)
 	if err != nil {
 		t.Fatalf("Failed to create ServiceProfile: %v", err)
 	}