Detect in-cluster namespace from service account file#113
Closed
Copilot wants to merge 4 commits intofeat/in-cluster-supportfrom
Closed
Detect in-cluster namespace from service account file#113Copilot wants to merge 4 commits intofeat/in-cluster-supportfrom
Copilot wants to merge 4 commits intofeat/in-cluster-supportfrom
Conversation
- Add detectInClusterNamespace() helper function to read namespace from /var/run/secrets/kubernetes.io/serviceaccount/namespace - Update LoadInClusterConfig to use the detected namespace instead of hardcoded "default" - Add comprehensive test cases for namespace detection logic - Include namespace in in-cluster config loading log message Co-authored-by: basebandit <8973567+basebandit@users.noreply.github.com>
- Extract readNamespaceFromFile function to enable proper unit testing - Update tests to test the actual function rather than duplicating logic - Add test for detectInClusterNamespace default behavior - Remove unused strings import from test file Co-authored-by: basebandit <8973567+basebandit@users.noreply.github.com>
Co-authored-by: basebandit <8973567+basebandit@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Update implementation based on feedback for in-cluster support
Detect in-cluster namespace from service account file
Feb 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When running in a Kubernetes pod, the namespace was hardcoded to "default" instead of detecting the actual namespace. This made the in-cluster context inaccurate for pods running in other namespaces.
Changes
detectInClusterNamespace(): Reads namespace from/var/run/secrets/kubernetes.io/serviceaccount/namespace, the standard Kubernetes service account mountreadNamespaceFromFile(): Testable helper that handles file I/O with fallback to "default" on errors (missing file, empty content)LoadInClusterConfig(): Uses detected namespace instead of hardcoded "default"Example
Type of change
Checklist:
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.