feat: add Gateway discovery to detect unused Gateway API resources#505
Draft
feat: add Gateway discovery to detect unused Gateway API resources#505
Conversation
Co-authored-by: yonahd <47282577+yonahd@users.noreply.github.com>
Co-authored-by: yonahd <47282577+yonahd@users.noreply.github.com>
Co-authored-by: yonahd <47282577+yonahd@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Feature: Discover unused gateways
feat: add Gateway discovery to detect unused Gateway API resources
Sep 17, 2025
Copilot stopped work on behalf of
yonahd due to an error
September 17, 2025 20:14
Owner
|
@copilot please follow the contributing docs https://github.com/yonahd/kor/blob/main/CONTRIBUTING.md |
…te.go and create_test_resources.go Co-authored-by: yonahd <47282577+yonahd@users.noreply.github.com>
Contributor
Author
I've now completed all requirements from the CONTRIBUTING.md guide (commit 7e0262a): Added/Updated Files:
Technical Note: All tests passing ✓ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements Gateway discovery functionality to identify unused Gateway API resources in Kubernetes clusters. The feature addresses the common issue where Gateways are created but become orphaned due to missing GatewayClasses or detached Routes.
What this PR does / why we need it?
Gateway Detection Logic:
kor alland multi-resource commandsCommand Interface:
Example Output:
PR Checklist
Technical Implementation
Following the CONTRIBUTING.md guide, this PR includes all required files:
sigs.k8s.io/gateway-apiv1.0.0 dependencypkg/kor/gateways.gowith Gateway discovery logicpkg/kor/gateways_test.gocovering all scenarios including TCP/UDP routesCreateTestGateway,CreateTestGatewayClass, andCreateTestHTTPRoutehelpers inpkg/kor/create_test_resources.gopkg/kor/all.goforkor allcommandpkg/kor/multi.gofor comma-separated queriesprocessNamespaceGateways()with delete flagpkg/kor/exporter.gofor Prometheus metricscmd/kor/gateways.gofor standalone gateway discoveryGetGatewayClient()utility inpkg/kor/kor.gocharts/kor/templates/role.yamlwith Gateway API permissionspkg/kor/exceptions/gateways/gateways.jsonGateway API Client Handling:
Since Gateway API requires a separate client (
sigs.k8s.io/gateway-api/pkg/client/clientset/versioned), this PR follows the established pattern of passing multiple specialized clients (similar toapiExtClientanddynamicClient) throughout the codebase to maintain consistency and backward compatibility.Route Type Support
The implementation checks for all major Gateway API route types:
Backwards Compatibility
All existing functionality remains unchanged. The feature follows established kor patterns and doesn't modify any existing resource detection logic. All existing tests continue to pass.
GitHub Issue
Closes #504
Notes for your reviewers
This implementation fully adheres to the repository's contribution guidelines. All required files per CONTRIBUTING.md have been created/updated. The Gateway client is consistently passed through all affected functions to maintain the existing architectural patterns.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.