- 
                Notifications
    You must be signed in to change notification settings 
- Fork 451
frontend: network: Add support for Admin Network Policy resources #3601
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| [APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: frozenprocess 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  | 
| Welcome @frozenprocess!  | 
| @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. | 
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
| 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. | 
There was a problem hiding this 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', | 
    
      
    
      Copilot
AI
    
    
    
      Oct 8, 2025 
    
  
There was a problem hiding this comment.
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'.
| name: 'default-egress', | |
| name: 'default-ingress', | 
| export interface AdminNetworkPolicyPort { | ||
| portNumber?: Port; | ||
| namedPort?: string; | ||
| portRange?: Port; | 
    
      
    
      Copilot
AI
    
    
    
      Oct 8, 2025 
    
  
There was a problem hiding this comment.
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.
| portRange?: Port; | |
| portRange?: PortRange; | 
| adminnetworkpolicy?.jsonData?.spec?.egress?.length ?? | ||
| adminnetworkpolicy?.jsonData?.spec?.ingress?.length, | 
    
      
    
      Copilot
AI
    
    
    
      Oct 8, 2025 
    
  
There was a problem hiding this comment.
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).
| adminnetworkpolicy?.jsonData?.spec?.egress?.length ?? | |
| adminnetworkpolicy?.jsonData?.spec?.ingress?.length, | |
| (adminnetworkpolicy?.jsonData?.spec?.egress?.length ?? 0) + | |
| (adminnetworkpolicy?.jsonData?.spec?.ingress?.length ?? 0), | 
| AdminNetworkPolicy.jsonData?.spec?.subject?.namespaces?.namespaceSelector | ||
| ?.matchLabels | 
    
      
    
      Copilot
AI
    
    
    
      Oct 8, 2025 
    
  
There was a problem hiding this comment.
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).
| AdminNetworkPolicy.jsonData?.spec?.subject?.namespaces?.namespaceSelector | |
| ?.matchLabels | |
| AdminNetworkPolicy.jsonData?.spec?.subject?.namespaces?.matchLabels | 
| </> | ||
| ) : ( | ||
| <Typography sx={metadataStyles} display="inline"> | ||
| All Pods | 
    
      
    
      Copilot
AI
    
    
    
      Oct 8, 2025 
    
  
There was a problem hiding this comment.
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.
| All Pods | |
| All Namespaces | 
| 
 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: 
 | 


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
[ 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
2a. create an ANP
2b. view your ANP
2c. delete your ANP
Screenshots (if applicable)
Notes for the Reviewer