frontend: pod: Add target container support to debug containers - #5937
frontend: pod: Add target container support to debug containers#5937yush-1018 wants to merge 3 commits into
Conversation
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.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: yush-1018 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
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.addEphemeralContainerto optionally settargetContainerNameon 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
left a comment
There was a problem hiding this comment.
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.
illume
left a comment
There was a problem hiding this comment.
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.
|
PR needs rebase. DetailsInstructions 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
left a comment
There was a problem hiding this comment.
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.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: yush-1018 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @illume @yush-1018! |
Summary
This PR adds target container support to Headlamp's ephemeral debug containers.
When debugging a pod:
Targeting shares the process namespace and filesystem (via
/proc/<pid>/root) of the application container, making debugging much more useful.Key Changes
targetContainerNametoKubeContainertypes and removedanyfromfindRunningDebugContainer.Related Issues
Fixes #4914
Supersedes #5461