Skip to content

frontend: pod: Add target container support to debug containers - #5937

Open
yush-1018 wants to merge 3 commits into
kubernetes-sigs:mainfrom
yush-1018:fix/debug-container-target-4914-v2
Open

frontend: pod: Add target container support to debug containers#5937
yush-1018 wants to merge 3 commits into
kubernetes-sigs:mainfrom
yush-1018:fix/debug-container-target-4914-v2

Conversation

@yush-1018

Copy link
Copy Markdown

Summary

This PR adds target container support to Headlamp's ephemeral debug containers.

When debugging a pod:

  • Single-container pods: The debug shell automatically targets the container.
  • Multi-container pods: Users get a dialog to select which container to target (or choose "None").

Targeting shares the process namespace and filesystem (via /proc/<pid>/root) of the application container, making debugging much more useful.

Key Changes

  • Added a container selector dialog for multi-container pods.
  • Added targetContainerName to KubeContainer types and removed any from findRunningDebugContainer.
  • Added new Storybook stories and updated English/Hindi localization keys.

Related Issues

Fixes #4914
Supersedes #5461

This adds support for selecting a target container when debugging a pod, enabling process namespace sharing and filesystem inspection. We also resolved type issues, added comprehensive Storybook stories, and verified translations.
@k8s-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: yush-1018
Once this PR has been reviewed and has the lgtm label, please assign joaquimrocha for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Jun 7, 2026
@k8s-ci-robot
k8s-ci-robot requested review from illume and sniok June 7, 2026 06:21
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jun 7, 2026
@illume
illume requested a review from Copilot June 7, 2026 08:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements Kubernetes ephemeral debug container targeting for pods, enabling the debug container to share namespaces (PID/IPC/etc.) with a chosen application container. This improves the usefulness of Headlamp’s “Debug Pod” flow by aligning it with the targetContainerName capability in the K8s ephemeral container API.

Changes:

  • Extended Pod.addEphemeralContainer to optionally set targetContainerName on the ephemeral container spec, and added a unit test to validate the PATCH body behavior.
  • Updated the pod debug terminal flow to (a) select/attach to an existing running debug container that matches the requested target and (b) create a targeted debug container when needed.
  • Added a UI container-target picker for multi-container pods, plus Storybook stories/snapshots and new i18n keys across locales.

Reviewed changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated no comments.

Show a summary per file
File Description
frontend/src/lib/k8s/pod.ts Adds optional targetContainerName support when creating ephemeral containers.
frontend/src/lib/k8s/pod.test.ts Adds tests asserting targetContainerName is included/omitted in the PATCH body.
frontend/src/lib/k8s/cluster.ts Extends KubeContainer type to include optional targetContainerName.
frontend/src/components/pod/PodDebugTerminal.tsx Threads target selection through debug creation/attachment and removes any from findRunningDebugContainer.
frontend/src/components/pod/PodDebugAction.tsx Adds multi-container target selection dialog; single-container pods auto-target their only container.
frontend/src/components/pod/PodDebugTerminal.stories.tsx Adds stories for targeted debugging and a multi-container pod mock; updates MSW handlers.
frontend/src/components/pod/snapshots/PodDebugTerminal.Default.stories.storyshot Updates snapshots to reflect new terminal wrapper/layout and output.
frontend/src/components/pod/snapshots/PodDebugTerminal.WithTargetContainer.stories.storyshot New snapshot for targeted debug terminal story.
frontend/src/components/pod/snapshots/PodDebugTerminal.MultiContainerWithTarget.stories.storyshot New snapshot for multi-container targeted debug terminal story.
frontend/src/i18n/locales/en/translation.json Adds new debug-targeting UI strings in English.
frontend/src/i18n/locales/hi/translation.json Adds Hindi translations for the new debug-targeting UI strings.
frontend/src/i18n/locales/ar/translation.json Adds new keys (empty values fall back to English).
frontend/src/i18n/locales/de/translation.json Adds new keys (empty values fall back to English).
frontend/src/i18n/locales/es/translation.json Adds new keys (empty values fall back to English).
frontend/src/i18n/locales/fr/translation.json Adds new keys (empty values fall back to English).
frontend/src/i18n/locales/he/translation.json Adds new keys (empty values fall back to English).
frontend/src/i18n/locales/it/translation.json Adds new keys (empty values fall back to English).
frontend/src/i18n/locales/ja/translation.json Adds new keys (empty values fall back to English).
frontend/src/i18n/locales/ko/translation.json Adds new keys (empty values fall back to English).
frontend/src/i18n/locales/pt/translation.json Adds new keys (empty values fall back to English).
frontend/src/i18n/locales/ru/translation.json Adds new keys (empty values fall back to English).
frontend/src/i18n/locales/ta/translation.json Adds new keys (empty values fall back to English).
frontend/src/i18n/locales/ur/translation.json Adds new keys (empty values fall back to English).
frontend/src/i18n/locales/zh/translation.json Adds new keys (empty values fall back to English).
frontend/src/i18n/locales/zh-tw/translation.json Adds new keys (empty values fall back to English).

@illume illume left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution.

The GitHub CI test job has snapshot failures. Run cd frontend && npm run test -- -u to regenerate the snapshots.

How to update snapshots

Run cd frontend && npm run test -- -u to regenerate all snapshots. Review the diff to make sure the visual changes are intentional, then commit the updated snapshot files.

@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jun 7, 2026

@illume illume left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for these changes.

can you please rebase against main to remove the merge main commit?

Why this matters

Merge commits from main make the PR history harder to review. Please rebase your branch on top of the latest main instead, then update the PR with the rebased commits.

I noticed the GitHub CI frontend lint job is failing. Can you please fix the lint errors? You can run cd frontend && npm run lint locally to see the errors.

How to fix lint errors

Run cd frontend && npm run lint to see all ESLint errors. Many can be fixed automatically with cd frontend && npm run lint -- --fix. Remaining errors need manual attention.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 25 out of 25 changed files in this pull request and generated no new comments.

@kubernetes-prow kubernetes-prow Bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 26, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

PR needs rebase.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@illume illume left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for these changes.

It looks like this PR has git conflicts. Can you please fix them?

How to resolve conflicts

Rebase or merge the latest main into your branch, resolve the conflicts, and push the updated branch.

@kubernetes-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: yush-1018
Once this PR has been reviewed and has the lgtm label, please assign joaquimrocha for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@illume illume added collab Collaborative work across contributors frontend Issues related to the frontend kind/feature Categorizes issue or PR as related to a new feature. testing labels Jul 25, 2026
@illume illume added this to the v0.44.0 milestone Jul 27, 2026
@illume illume modified the milestones: v0.44.0, v0.45.0 Jul 28, 2026
@Suyog241005

Suyog241005 commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Hi @illume @yush-1018!
I noticed this PR is in the active v0.45.0 milestone but has open conflicts and failing CI checks.
I'd be happy to take this over for the milestone. I can rebase it cleanly onto latest main, fix the lint errors and fix the CI build failures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. collab Collaborative work across contributors frontend Issues related to the frontend kind/feature Categorizes issue or PR as related to a new feature. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Debug container does not share filesystem or process space with other containers

6 participants