feat: Add Path Parameter Support for kubeconfigID Permalinks#4645
Open
pbochynski wants to merge 2 commits intokyma-project:mainfrom
Open
feat: Add Path Parameter Support for kubeconfigID Permalinks#4645pbochynski wants to merge 2 commits intokyma-project:mainfrom
pbochynski wants to merge 2 commits intokyma-project:mainfrom
Conversation
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
This PR adds support for a
pathparameter in kubeconfigID permalinks, allowing users to navigate directly to a specific resource view after loading a kubeconfig.Problem
Currently, when using
kubeconfigIDpermalinks (e.g.,/?kubeconfigID=abc123), users are always redirected to the cluster overview after authentication. There's no way to create a permalink that navigates to a specific resource like pods, deployments, or a specific namespace.Solution
Added a new
pathparameter that can be used alongsidekubeconfigIDto specify the intended navigation path:The path is stored in sessionStorage during app initialization and used after authentication is complete, ensuring proper navigation timing even with OIDC authentication flows.
Changes
New Files
src/state/intendedPathAtom.tssaveIntendedPath,getIntendedPath,clearIntendedPath,initIntendedPathFromUrlpublic/kubeconfig/README.mdpublic/kubeconfig/.gitignoreModified Files
src/index.tsxinitIntendedPathFromUrl()at app initializationpathparameter from URL before React Router processes the routesrc/components/Clusters/shared.tsaddCurrentClusterfunction to check for intended pathgetIntendedPathfromintendedPathAtomsrc/state/useAfterInitHook.tsUsage
URL Format
Examples
/?kubeconfigID=test&path=/namespaces/default/pods/?kubeconfigID=test&path=/namespaces/kube-system/deployments/?kubeconfigID=test&path=/nodes/?kubeconfigID=test&path=/overview/?kubeconfigID=test&path=/namespaces/default/pods/my-podPath Format
The
pathparameter should be the path relative to the cluster root:/namespaces/<namespace>/<resource-type>- List resources in a namespace/namespaces/<namespace>/<resource-type>/<resource-name>- Specific resource details/<cluster-resource-type>- Cluster-scoped resources (e.g.,/nodes,/clusterroles)/overview- Cluster overviewLocal Development Testing
The existing
KUBECONFIG_IDfeature flag is already configured withkubeconfigUrl: /kubeconfigby default. This means kubeconfig files placed inpublic/kubeconfig/are served automatically by Vite.Setup
Copy your kubeconfig file to
public/kubeconfig/without a file extension:cp ~/.kube/config public/kubeconfig/testStart the dev server:
Test the permalink:
Security Note
public/kubeconfig/.gitignoreis configured to ignore all kubeconfig files to prevent accidentally committing sensitive credentials.Production Configuration
In production, configure the
KUBECONFIG_IDfeature flag in your Busola configuration:See Feature Flags Documentation for more details.
Implementation Details
Flow
/?kubeconfigID=test&path=/namespaces/default/podsinitIntendedPathFromUrl()saves the path to sessionStorageuseLoginWithKubeconfigIDfetches and loads the kubeconfigaddCurrentClusternavigates to cluster overview (auth setup happens)useAfterInitHookwaits for auth to be readyWhy This Approach?
The navigation to the intended path must happen after authentication is complete. If we navigate immediately when the cluster is added, the API calls to verify the namespace will fail with 400 errors because the auth headers aren't set yet.
By navigating to the cluster overview first and then redirecting to the intended path in
useAfterInitHook(which waits forauthDatato be available), we ensure all API calls work correctly.Related Issues
kubeconfigIDquery parameter fail to navigate to the intended resource path on first access #4644