diff --git a/cli/cmd/identity.go b/cli/cmd/identity.go index cd25cbc39..62e4c88ea 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 26beac805..7d3d52f1d 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" {