Skip to content

knative: implement dynamic sidebar filtering based on CRD discovery#720

Open
Joshna907 wants to merge 1 commit into
headlamp-k8s:mainfrom
Joshna907:fix/knative-sidebar-filtering
Open

knative: implement dynamic sidebar filtering based on CRD discovery#720
Joshna907 wants to merge 1 commit into
headlamp-k8s:mainfrom
Joshna907:fix/knative-sidebar-filtering

Conversation

@Joshna907
Copy link
Copy Markdown
Contributor

Summary

This PR refactors the Knative plugin's menu registration in the sidebar to implement dynamic, cluster-aware visibility filtering. It hides the entire Knative menu group when connected to a cluster where Knative's Serving components are not installed, matching Headlamp's visual quality standards.

Key changes

  • knative/src/index.tsx:
    • Imported K8s, Utils, and registerSidebarEntryFilter from the plugin SDK.
    • Implemented checkKnativeInstalled(cluster) with a lightweight caching and time-to-live (TTL) mechanism to search the cluster's Custom Resource Definitions (CRDs) for 'services.serving.knative.dev'.
    • Registered a sidebar entry filter to hide the knative parent and all child entries if Knative is not installed on the active cluster.

Why this is needed

  • UI Clutter: Statically registering Knative sidebar entries makes the menus permanently visible even on environments without Knative. Clicking them triggers dead views, leading to a cluttered and unpolished experience.
  • Active Context Sync: It guarantees that the sidebar navigation dynamically adapts when switching between different Kubernetes clusters with different capabilities.

Steps to test

  1. Switch to a Kubernetes cluster that does not have Knative installed.
  2. Verify that the Knative sidebar menu entry is completely hidden.
  3. Switch to a cluster with Knative installed.
  4. Verify that the Knative sidebar menu entry (and all its sub-pages: KServices, Revisions, Domain Mapping, Cluster Domain Claims, Networking) displays correctly.

Copy link
Copy Markdown
Contributor

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 PR adds cluster-aware sidebar filtering for the Knative plugin so the Knative menu can be hidden when the active cluster does not expose Knative Serving CRDs.

Changes:

  • Adds CRD discovery state, TTL caching, and in-flight tracking for Knative installation checks.
  • Registers a sidebar entry filter that hides the Knative parent and children when Knative is detected as absent.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread knative/src/index.tsx Outdated
Comment thread knative/src/index.tsx Outdated
Comment thread knative/src/index.tsx
Signed-off-by: Joshna907 <joshnawaikar@gmail.com>
@Joshna907 Joshna907 force-pushed the fix/knative-sidebar-filtering branch from b8e00bb to 369babd Compare May 18, 2026 13:13
@Joshna907
Copy link
Copy Markdown
Contributor Author

ptal now @illume

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants