Skip to content

Container not found for sidecar-injected containers when displaying env vars with resourceFieldRef #5106

@vmozghovyi

Description

@vmozghovyi

Describe the bug

When viewing environment variables for a pod that has sidecar containers injected via mutating webhook (e.g. Istio's istio-proxy), Headlamp displays "Container not found" for env vars that use resourceFieldRef referencing
the sidecar container.

For example, Istio injects env vars like:

- name: GOMAXPROCS
  valueFrom:
    resourceFieldRef:
      containerName: istio-proxy
      resource: limits.cpu
- name: GOMEMLIMIT
  valueFrom:
    resourceFieldRef:                                                                                                                                                                                                              
      containerName: istio-proxy
      resource: limits.memory                                                                                                                                                                                                      

Headlamp resolves resourceFieldRef by looking up the container in the pod spec from the API response. However, it appears to look at the deployment template spec rather than the running pod spec. Since sidecar
containers are injected at admission time by a mutating webhook, they exist in the running pod's spec.containers but not in the original deployment template.

Expected behavior

Headlamp should resolve resourceFieldRef using the container list from the actual Pod object (pod.spec.containers + pod.spec.initContainers), not from the Deployment template. This way, sidecar-injected containers
like istio-proxy would be found and their resource limits displayed correctly.

To Reproduce

  1. Deploy any workload in a namespace with Istio sidecar injection enabled
  2. Open the pod details in Headlamp
  3. Expand the environment variables section for the istio-proxy container
  4. Observe "Container istio-proxy not found" messages for GOMAXPROCS, GOMEMLIMIT, ISTIO_CPU_LIMIT env vars

Environment

  • Headlamp Version: 0.41.0
  • Installation: In-cluster (Helm chart)
  • Kubernetes Version: 1.33
  • Istio Version: 1.26 (sidecar injection via mutating webhook)

Would you like to fix this bug?

No

Additional context

This affects any sidecar injected via mutating admission webhook, not just Istio. The same issue would occur with Linkerd, Dapr, or any other service mesh / sidecar injector.

Introduced in v0.31.0 via PR #2728.

Image

Metadata

Metadata

Assignees

Labels

kind/bugCategorizes issue or PR as related to a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions