Skip to content

project: Add ability to import and convert namespaces into projects#314

Open
gambtho wants to merge 4 commits intoAzure:mainfrom
gambtho:thgamble/nstoproj
Open

project: Add ability to import and convert namespaces into projects#314
gambtho wants to merge 4 commits intoAzure:mainfrom
gambtho:thgamble/nstoproj

Conversation

@gambtho
Copy link
Collaborator

@gambtho gambtho commented Feb 24, 2026

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

  • Rewrites ImportAKSProjects to discover all managed namespaces (not just pre-labeled ones) via Azure Resource Graph
  • Adds an "AKS Project?" status column showing whether each namespace already has AKS Desktop labels
  • When importing namespaces that aren't yet projects, a ConversionDialog confirms label application (headlamp.dev/project-managed-by: aks-desktop) before proceeding
  • Handles permission errors gracefully with clear messaging

Shared Utilities

  • Extracts assignRolesToNamespace() from CreateAKSProject into utils/azure/roleAssignment.ts for reuse
  • Adds applyProjectLabels() and fetchNamespaceData() in utils/kubernetes/namespaceUtils.ts for K8s label operations
  • Refactors CreateAKSProject.tsx to use the shared role assignment utility (~130 lines removed)

New Components

  • ConversionDialog — confirmation popup disclosing which labels will be added
  • useNamespaceDiscovery hook — Resource Graph discovery with isAksProject status, system namespace filtering, already-imported filtering
  • CreateProjectFromNamespace wizard — 5-step flow for advanced conversion (namespace selection, networking, compute, access, review)

Other

  • Adds documentation links in README
  • Registers new routes and create-project options in index.tsx

File Changes

Category Files
New ConversionDialog.tsx, ImportAKSProjects/hooks/useNamespaceDiscovery.ts, CreateProjectFromNamespace/ (wizard + components + hook), roleAssignment.ts, namespaceUtils.ts
Modified ImportAKSProjects.tsx (rewrite), CreateAKSProject.tsx (refactor), index.tsx (registrations), README.md
Tests namespaceUtils.test.ts (10 tests), roleAssignment.test.ts (9 tests)

Test plan

  • All CI checks pass (tsc, lint, format, build, tests)
  • ImportAKSProjects page shows all managed namespaces with "AKS Project?" column
  • Selecting already-labeled namespaces imports directly without dialog
  • Selecting unlabeled namespaces shows ConversionDialog with label disclosure
  • Confirming conversion applies labels and imports successfully
  • Permission denied errors show clear messaging
  • CreateAKSProject wizard still works after role assignment refactor
  • CreateProjectFromNamespace wizard works end-to-end for advanced conversion

Copilot AI review requested due to automatic review settings February 24, 2026 19:53
Copy link

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 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.

@gambtho gambtho changed the title project: Add ability to create projects from existing managed namespaces project: Add ability to import and convert namespaces into projects Feb 24, 2026
Copilot AI review requested due to automatic review settings February 25, 2026 00:26
Copy link

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

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.

Copilot AI review requested due to automatic review settings February 25, 2026 04:51
Copy link

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

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.

Copy link
Collaborator

@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.

Can you please break this down into some smaller commits?

Copilot AI review requested due to automatic review settings February 25, 2026 14:36
Copy link

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

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.

@gambtho gambtho requested a review from illume February 25, 2026 14:49
Copilot AI review requested due to automatic review settings February 25, 2026 15:03
Copy link

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

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.

Copilot AI review requested due to automatic review settings February 25, 2026 23:01
Copy link

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

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.

Copilot AI review requested due to automatic review settings February 26, 2026 15:11
Copy link

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

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.

@illume
Copy link
Collaborator

illume commented Feb 27, 2026

@gambtho can you please add the issue into the PR description?

Found it:

@illume illume added p3 low priority enhancement New feature or request labels Feb 27, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request p3 low priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants