Skip to content

frontend: Add environment variables display for containers#4476

Merged
k8s-ci-robot merged 1 commit intokubernetes-sigs:mainfrom
gambtho:show-container-env-vars-v2
Feb 12, 2026
Merged

frontend: Add environment variables display for containers#4476
k8s-ci-robot merged 1 commit intokubernetes-sigs:mainfrom
gambtho:show-container-env-vars-v2

Conversation

@gambtho
Copy link
Contributor

@gambtho gambtho commented Jan 28, 2026

Summary

Display environment variables per container in pod details with enhanced functionality:

  • Values from Secrets hidden by default with reveal on click
  • Copy to clipboard functionality using notistack
  • Links to referenced ConfigMaps and Secrets
  • Warning for out-of-sync resources (when ConfigMap/Secret is newer than pod start)
  • Support for valueFrom (secretKeyRef, configMapKeyRef, fieldRef, resourceFieldRef)
  • Support for envFrom (secretRef, configMapRef)

The implementation uses a proper React hooks pattern with separate fetcher components to avoid rules-of-hooks violations.

Based on PR #2728 by @vlasov-y and PR #3167 by @joaquimrocha

Test plan

  • View pod with env vars from manifest values
  • View pod with env vars from Secrets (values hidden, can reveal)
  • View pod with env vars from ConfigMaps
  • View pod with envFrom (secretRef) - all keys displayed
  • View pod with envFrom (configMapRef) - all keys displayed
  • View pod with fieldRef env vars (e.g., metadata.name)
  • View pod with resourceFieldRef env vars (e.g., limits.memory)
  • Click copy button - snackbar confirmation appears
  • Click reveal button on secret values - value shown
  • Verify out-of-sync warning appears when ConfigMap/Secret is newer than pod
  • Click links to Secrets/ConfigMaps - navigates correctly

@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jan 28, 2026
@gambtho gambtho force-pushed the show-container-env-vars-v2 branch from 65f730c to ee11d3c Compare January 28, 2026 21:49
@gambtho
Copy link
Contributor Author

gambtho commented Jan 28, 2026

image

@gambtho gambtho force-pushed the show-container-env-vars-v2 branch 2 times, most recently from 2b8c390 to 66a863d Compare February 1, 2026 14:09
@illume illume requested a review from Copilot February 1, 2026 14:48
Copy link
Contributor

Copilot AI left a comment

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 adds a comprehensive environment variables display feature for containers in pod details. It displays environment variables from multiple sources (manifest values, Secrets, ConfigMaps, field references, resource field references) with functionality to reveal/hide secret values, copy to clipboard, link to referenced resources, and warn about out-of-sync resources.

Changes:

  • Added ContainerEnvironmentVariables component with proper React hooks patterns
  • Implemented resource fetching with separate fetcher components
  • Added utility function divideK8sResources for resource field reference calculations
  • Updated Secret Details to handle base64 encoding correctly
  • Added translations for new UI elements

Reviewed changes

Copilot reviewed 119 out of 119 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
frontend/src/components/common/Resource/Resource.tsx Main implementation: ContainerEnvironmentVariables component, fetcher components, and environment variable processing logic
frontend/src/lib/units.ts Added divideK8sResources function for resource calculations
frontend/src/lib/units.test.ts Comprehensive tests for divideK8sResources
frontend/src/components/secret/Details.tsx Updated to keep data in base64 format
frontend/src/i18n/locales/*/translation.json Added translation for out-of-sync warning
frontend/src/plugin/snapshots/pluginLib.snapshot Updated plugin exports
Multiple snapshot files Updated to reflect UI changes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@illume
Copy link
Contributor

illume commented Feb 1, 2026

It looks like the snapshot tests need updating…
npm run test — -u

@gambtho gambtho force-pushed the show-container-env-vars-v2 branch from 66a863d to 21e3553 Compare February 1, 2026 17:17
Copy link
Contributor

@illume illume left a comment

Choose a reason for hiding this comment

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

Sorry I missed this before...

I think Resource should be added to the context part of the commit message subject to make it clearer where the change applies to.

frontend: Resource: Add environment variables display for containers

@gambtho gambtho force-pushed the show-container-env-vars-v2 branch 2 times, most recently from 3b1cdf6 to d9495a6 Compare February 1, 2026 19:36
@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 Feb 1, 2026
@gambtho gambtho force-pushed the show-container-env-vars-v2 branch 3 times, most recently from 454200a to 0410af9 Compare February 1, 2026 19:45
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Feb 1, 2026
@gambtho gambtho force-pushed the show-container-env-vars-v2 branch from 0410af9 to 6dd2c8e Compare February 1, 2026 20:16
@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 Feb 1, 2026
@gambtho gambtho force-pushed the show-container-env-vars-v2 branch 2 times, most recently from 6cb02b6 to b912560 Compare February 2, 2026 00:12
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Feb 2, 2026
@gambtho gambtho force-pushed the show-container-env-vars-v2 branch from b912560 to 7d1cff7 Compare February 2, 2026 02:02
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 3, 2026
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 11, 2026
Copy link
Contributor

@illume illume left a comment

Choose a reason for hiding this comment

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

Hello. Could you please rebase against main to remove the merge commit?

it looks like the frontend test github check is failing. Are you able to have a look?

@gambtho gambtho force-pushed the show-container-env-vars-v2 branch 2 times, most recently from 6aae8e8 to c3554df Compare February 12, 2026 00:45
Copy link
Contributor

@illume illume left a comment

Choose a reason for hiding this comment

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

The frontend tests are failing again... could you please try rebasing against main, then updating the snapshot tests?

I think there might be some fixes in the main branch.

@gambtho gambtho force-pushed the show-container-env-vars-v2 branch from c3554df to 66c3bf5 Compare February 12, 2026 15:20
@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 Feb 12, 2026
Copy link
Contributor

@illume illume left a comment

Choose a reason for hiding this comment

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

🎉 thanks!

(Can you please ask for someone else to review this in the headlamp channel on the kubernetes slack?)

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 12, 2026
@joaquimrocha
Copy link
Contributor

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 12, 2026
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gambtho, illume, joaquimrocha

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

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [illume,joaquimrocha]

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 merged commit b0279d4 into kubernetes-sigs:main Feb 12, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants