From 42dbdaddf5215550c1bef47e66acc21ce2851be6 Mon Sep 17 00:00:00 2001 From: Alejandro Pedraza Date: Tue, 16 Apr 2024 15:05:38 -0500 Subject: [PATCH] Fix 'linkerd identity' --- cli/cmd/identity.go | 3 ++- pkg/k8s/k8s.go | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cli/cmd/identity.go b/cli/cmd/identity.go index cd25cbc39a7bd..62e4c88eadd51 100644 --- a/cli/cmd/identity.go +++ b/cli/cmd/identity.go @@ -161,7 +161,8 @@ func getContainerWithPort(pod corev1.Pod, portName string) (corev1.Container, er return container, fmt.Errorf("pod not running: %s", pod.GetName()) } - for _, c := range pod.Spec.Containers { + containers := append(pod.Spec.InitContainers, pod.Spec.Containers...) + for _, c := range containers { if c.Name != k8s.ProxyContainerName { continue } diff --git a/pkg/k8s/k8s.go b/pkg/k8s/k8s.go index 26beac805d783..7d3d52f1d8413 100644 --- a/pkg/k8s/k8s.go +++ b/pkg/k8s/k8s.go @@ -239,7 +239,8 @@ func PodIdentity(pod *corev1.Pod) (string, error) { podsa := pod.Spec.ServiceAccountName podns := pod.ObjectMeta.Namespace - for _, c := range pod.Spec.Containers { + containers := append(pod.Spec.InitContainers, pod.Spec.Containers...) + for _, c := range containers { if c.Name == ProxyContainerName { for _, env := range c.Env { if env.Name == "LINKERD2_PROXY_IDENTITY_LOCAL_NAME" {