Dashboard namespace empty and backend connectivity issues #985
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.
While using Kagent, I noticed that although Kagent was installed correctly in the kagent namespace and my CLI config had the correct namespace set, running kagent dashboard showed the namespace dropdown as empty and the dashboard failed to display agents and models.
Root Cause
After investigation, the issue boiled down to two key problems:
CLI Configuration Initialization
The CLI code was not loading the configuration file (~/.kagent/config.yaml) before parsing command-line flags. This caused it to ignore the configured namespace and other settings, leading to the dashboard commands querying the wrong or no namespace, resulting in empty namespace displays.
UI Backend Connectivity and DNS Resolution
The dashboard UI tried to talk to the backend controller using the controller’s full DNS name (e.g., kagent-controller.kagent.svc.cluster.local). However, DNS resolution for this full name failed inside the UI container due to cluster DNS issues, causing errors when fetching models and agents, and resulting in HTTP 500 errors on the UI side.
Changes Made
To fix these issues, I made the following changes:
Fix CLI Config Loading Order
Modified the CLI’s main function to initialize the config file before processing CLI flags. This ensures the CLI properly respects the namespace and all other user-configured settings.
Update Helm UI Deployment Template
Changed the UI’s backend URL environment variable in the Helm chart from using the full DNS name to using the short Kubernetes service name (kagent-controller).
This leverages Kubernetes’ built-in DNS search domains that reliably resolve short names within the same namespace, avoiding DNS resolution failures.
Impact
These fixes make sure the dashboard properly displays the configured namespace, and the UI correctly fetches and displays agents and models without errors or empty
If the namespace were empty or not being read correctly, you would see a blank dashboard with no agents or models listed.