Skip to content

Conversation

@frozenprocess
Copy link

@frozenprocess frozenprocess commented Jul 9, 2025

This change adds CRUD support for ANP.

Summary

This PR adds/fixes [feature/bug] by [brief description of what the change does].

frontend: Add support for ANP resources which can be found under the Network section.

Related Issue

Fixes #3575

Changes

  • Added an ANP component to the UI
  • Added a Kube Object to headlamp lib to represent ANP

[ x ] Having a dedicated sub menu link in the Network section for ANPs
[ x ] Create ANPs using the + button in the ANP link
[ x ] ANP List view
[ x ] ANP Detail view

Steps to Test

  1. Navigate to Network section
  2. Click on Admin Network policies (alpha)
    2a. create an ANP
    2b. view your ANP
    2c. delete your ANP
  3. submit a feedback here :)

Screenshots (if applicable)

Notes for the Reviewer

  • [e.g., This touches the i18n layer, so please check language consistency.]

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jul 9, 2025
@k8s-ci-robot k8s-ci-robot requested review from sniok and vyncent-t July 9, 2025 04:03
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: frozenprocess
Once this PR has been reviewed and has the lgtm label, please assign illume for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot
Copy link
Contributor

Welcome @frozenprocess!

It looks like this is your first PR to kubernetes-sigs/headlamp 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/headlamp has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jul 9, 2025
@frozenprocess
Copy link
Author

I could use a bit of help on this. Unlike KNP, ANPs have subject which could be either pods or namespaces. I'm trying to find a good way to represent them

  1. method one: we use icon and labels with a tooltip that explains each icon if you hover over it
image 2. Method two: we use text image Judges? :)

@mazdakn
Copy link

mazdakn commented Jul 18, 2025

@frozenprocess I personally think option 2 is better than 1. But is it possible to use icons before each subject selector for differentiation?

@frozenprocess
Copy link
Author

@frozenprocess I personally think option 2 is better than 1. But is it possible to use icons before each subject selector for differentiation?

Yep, did some testing and it is possible to put an icon before each subject selector.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 5, 2025
ANP - Alpha support
- This change adds CRUD support for ANP.
- Added an ANP component to the UI
- Added a Kube Object to headlamp lib to represent ANP
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 5, 2025
@frozenprocess
Copy link
Author

Admin network policy is going through some changes, and it will be renamed. However, this will not change our effort to have it ready for the Beta release in Headlamp.

@illume illume requested a review from Copilot October 8, 2025 22:23
Copy link
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

Adds CRUD support for Admin Network Policy (ANP) resources in the frontend, integrating them into the Network section of the UI.

  • Added AdminNetworkPolicy Kubernetes object class with TypeScript interfaces
  • Implemented list and detail views for ANP resources
  • Added routing and sidebar navigation for ANP pages

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
frontend/src/lib/router/index.tsx Added routing configuration for ANP list and detail pages
frontend/src/lib/k8s/adminnetworkpolicy.tsx Created Kubernetes object class and TypeScript interfaces for ANP resources
frontend/src/components/adminnetworkpolicy/List.tsx Implemented list view component displaying ANP resources in a table
frontend/src/components/adminnetworkpolicy/Details.tsx Implemented detailed view component for individual ANP resources
frontend/src/components/Sidebar/useSidebarItems.ts Added ANP entry to Network section sidebar menu

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

},
},
],
name: 'default-egress',
Copy link

Copilot AI Oct 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ingress rule is incorrectly named 'default-egress' when it should be 'default-ingress'.

Suggested change
name: 'default-egress',
name: 'default-ingress',

Copilot uses AI. Check for mistakes.
export interface AdminNetworkPolicyPort {
portNumber?: Port;
namedPort?: string;
portRange?: Port;
Copy link

Copilot AI Oct 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The portRange field should be of type PortRange, not Port, to match the interface definition.

Suggested change
portRange?: Port;
portRange?: PortRange;

Copilot uses AI. Check for mistakes.
Comment on lines +45 to +46
adminnetworkpolicy?.jsonData?.spec?.egress?.length ??
adminnetworkpolicy?.jsonData?.spec?.ingress?.length,
Copy link

Copilot AI Oct 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic incorrectly returns ingress length when egress is 0, instead of summing both ingress and egress rule counts. Should be (adminnetworkpolicy?.jsonData?.spec?.egress?.length ?? 0) + (adminnetworkpolicy?.jsonData?.spec?.ingress?.length ?? 0).

Suggested change
adminnetworkpolicy?.jsonData?.spec?.egress?.length ??
adminnetworkpolicy?.jsonData?.spec?.ingress?.length,
(adminnetworkpolicy?.jsonData?.spec?.egress?.length ?? 0) +
(adminnetworkpolicy?.jsonData?.spec?.ingress?.length ?? 0),

Copilot uses AI. Check for mistakes.
Comment on lines +108 to +109
AdminNetworkPolicy.jsonData?.spec?.subject?.namespaces?.namespaceSelector
?.matchLabels
Copy link

Copilot AI Oct 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The property path is incorrect. Based on the interface definition, it should be AdminNetworkPolicy.jsonData?.spec?.subject?.namespaces?.matchLabels (namespaces is a LabelSelector, not containing a namespaceSelector property).

Suggested change
AdminNetworkPolicy.jsonData?.spec?.subject?.namespaces?.namespaceSelector
?.matchLabels
AdminNetworkPolicy.jsonData?.spec?.subject?.namespaces?.matchLabels

Copilot uses AI. Check for mistakes.
</>
) : (
<Typography sx={metadataStyles} display="inline">
All Pods
Copy link

Copilot AI Oct 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This text should be 'All Namespaces' since we're handling the namespaces subject case, not pods.

Suggested change
All Pods
All Namespaces

Copilot uses AI. Check for mistakes.
@illume
Copy link
Contributor

illume commented Oct 8, 2025

Admin network policy is going through some changes, and it will be renamed. However, this will not change our effort to have it ready for the Beta release in Headlamp.

Great. Looking forward to this. Please let us know if you have any questions in the mean time?

I see there are some errors in the GitHub checks... here's some tips:

  • You can update the snapshot tests with this: npm run test -- -u
  • npm run tsc to run the type checker

@illume illume added kind/feature Categorizes issue or PR as related to a new feature. frontend Issues related to the frontend k8s Kubernetes compatibility-related issues/features labels Oct 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. frontend Issues related to the frontend k8s Kubernetes compatibility-related issues/features kind/feature Categorizes issue or PR as related to a new feature. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for Admin Network Policy resources

4 participants