project: Add ability to import and convert namespaces into projects#314
project: Add ability to import and convert namespaces into projects#314gambtho wants to merge 4 commits intoAzure:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request adds a new "AKS project from existing namespace" feature that enables users to convert existing AKS managed namespaces into Headlamp projects. The feature addresses the gap where namespaces created outside AKS Desktop (via Azure CLI or Portal) could not be turned into projects. The implementation follows the codebase's established patterns and successfully extracts shared role assignment logic into reusable utilities.
Changes:
- New wizard flow for converting or importing managed namespaces with 5 steps: namespace selection, networking policies, compute quota, access control, and review
- Shared utility modules for role assignment (
roleAssignment.ts) and namespace label management (namespaceUtils.ts) - Azure Resource Graph-based namespace discovery with platform-specific query quoting for Windows compatibility
- Documentation links added to README for AKS Desktop and managed namespaces
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
utils/kubernetes/namespaceUtils.ts |
New utility for fetching namespace data via K8s API and applying project labels |
utils/azure/roleAssignment.ts |
Extracted shared role assignment logic from CreateAKSProject into reusable utility function |
hooks/useNamespaceDiscovery.ts |
New hook that discovers managed namespaces via Azure Resource Graph with categorization |
components/NamespaceSelectionStep.tsx |
Namespace picker UI with radio selection tables for conversion vs import categories |
components/FromNamespaceReviewStep.tsx |
Review step displaying labels, config, and user assignments before conversion |
CreateProjectFromNamespace.tsx |
Main wizard component orchestrating the 5-step conversion/import flow |
index.tsx |
Route and custom create project registration for new namespace conversion feature |
CreateAKSProject.tsx |
Refactored to use shared assignRolesToNamespace utility, reducing duplication |
README.md |
Added documentation section with links to AKS Desktop and managed namespaces docs |
docs/implementation-plan-namespace-to-project.md |
Comprehensive implementation plan document (800 lines) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
plugins/aks-desktop/src/components/CreateProjectFromNamespace/hooks/useNamespaceDiscovery.ts
Outdated
Show resolved
Hide resolved
plugins/aks-desktop/src/components/CreateProjectFromNamespace/CreateProjectFromNamespace.tsx
Outdated
Show resolved
Hide resolved
plugins/aks-desktop/src/components/CreateProjectFromNamespace/CreateProjectFromNamespace.tsx
Outdated
Show resolved
Hide resolved
35b38a6 to
bf3548f
Compare
bf3548f to
ea277f2
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 29 out of 29 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
.../aks-desktop/src/components/CreateProjectFromNamespace/components/NamespaceSelectionStep.tsx
Outdated
Show resolved
Hide resolved
.../aks-desktop/src/components/CreateProjectFromNamespace/components/NamespaceSelectionStep.tsx
Outdated
Show resolved
Hide resolved
plugins/aks-desktop/src/components/ImportAKSProjects/ImportAKSProjects.tsx
Show resolved
Hide resolved
ea277f2 to
675a74f
Compare
675a74f to
5f53f75
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 28 out of 28 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
plugins/aks-desktop/src/utils/shared/isAksProject.tsx:23
- The cancel function is not being called in the error callback. According to the codebase conventions, cancelFn must be awaited and called in both success and error callbacks to prevent resource leaks. Add
cancelFn.then(it => it());inside the error callback.
() => {
res(false);
},
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
illume
left a comment
There was a problem hiding this comment.
Can you please break this down into some smaller commits?
5f53f75 to
ec3a329
Compare
ec3a329 to
d90b62d
Compare
d90b62d to
ce30d98
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 27 out of 27 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
plugins/aks-desktop/src/components/CreateAKSProject/components/BasicsStep.tsx
Outdated
Show resolved
Hide resolved
plugins/aks-desktop/src/components/CreateAKSProject/CreateAKSProject.tsx
Outdated
Show resolved
Hide resolved
plugins/aks-desktop/src/components/ImportAKSProjects/ImportAKSProjects.tsx
Show resolved
Hide resolved
ce30d98 to
9ac09a4
Compare
9ac09a4 to
175a3c2
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 27 out of 27 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
plugins/aks-desktop/src/components/ImportAKSProjects/ImportAKSProjects.tsx
Outdated
Show resolved
Hide resolved
plugins/aks-desktop/src/components/ImportAKSProjects/components/ConversionDialog.test.tsx
Outdated
Show resolved
Hide resolved
0f43e69 to
b257e67
Compare
b257e67 to
0411f2c
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 27 out of 27 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
plugins/aks-desktop/src/components/CreateAKSProject/CreateAKSProject.tsx
Show resolved
Hide resolved
plugins/aks-desktop/src/components/CreateAKSProject/CreateAKSProject.tsx
Show resolved
Hide resolved
plugins/aks-desktop/src/components/ImportAKSProjects/ImportAKSProjects.tsx
Show resolved
Hide resolved
0411f2c to
7a59a6c
Compare
7a59a6c to
b9d61ef
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 27 out of 27 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@gambtho can you please add the issue into the PR description? Found it: |
Move hardcoded project label strings into utils/constants/projectLabels.ts and update all consumers (CreateAKSProject, DeleteAKSProject, InfoTab, Metrics, Scaling, isAksProject). Also fix useClustersConf import path.
Move the inline role assignment loop from CreateAKSProject into a reusable assignRolesToNamespace() function in utils/azure/roleAssignment.ts. This will also be used by the namespace import flow.
…ooks Add helper utilities for the namespace import feature: - namespaceUtils: fetch namespace data and apply project labels via K8s API - clusterSettings: read/write per-cluster localStorage settings - useRegisteredClusters: hook returning registered cluster names - useNamespaceDiscovery: discovers AKS managed namespaces (via Azure Resource Graph) and regular K8s namespaces, categorizing them as needing conversion or import Includes vitest config and tests for all new modules.
Rewrite the import page to use the new useNamespaceDiscovery hook, supporting both managed namespace import and regular namespace conversion to projects. Add ConversionDialog for converting unlabeled namespaces. Update plugin registration text and add documentation links to README.
b9d61ef to
7ec2064
Compare
Summary
Implements the namespace-to-project conversion experience allowing users to import existing AKS managed namespaces as AKS Desktop projects.
For issue:
Unified Import Page
ImportAKSProjectsto discover all managed namespaces (not just pre-labeled ones) via Azure Resource Graphheadlamp.dev/project-managed-by: aks-desktop) before proceedingShared Utilities
assignRolesToNamespace()fromCreateAKSProjectintoutils/azure/roleAssignment.tsfor reuseapplyProjectLabels()andfetchNamespaceData()inutils/kubernetes/namespaceUtils.tsfor K8s label operationsCreateAKSProject.tsxto use the shared role assignment utility (~130 lines removed)New Components
ConversionDialog— confirmation popup disclosing which labels will be addeduseNamespaceDiscoveryhook — Resource Graph discovery withisAksProjectstatus, system namespace filtering, already-imported filteringCreateProjectFromNamespacewizard — 5-step flow for advanced conversion (namespace selection, networking, compute, access, review)Other
index.tsxFile Changes
ConversionDialog.tsx,ImportAKSProjects/hooks/useNamespaceDiscovery.ts,CreateProjectFromNamespace/(wizard + components + hook),roleAssignment.ts,namespaceUtils.tsImportAKSProjects.tsx(rewrite),CreateAKSProject.tsx(refactor),index.tsx(registrations),README.mdnamespaceUtils.test.ts(10 tests),roleAssignment.test.ts(9 tests)Test plan
ImportAKSProjectspage shows all managed namespaces with "AKS Project?" columnCreateAKSProjectwizard still works after role assignment refactor