Is your feature request related to a problem? Please describe.
Gateways can be created while referencing non-existing GatewayClasses or can exist without any attached Routes (HTTPRoute, TCPRoute, UDPRoute, etc.).
This can leave unused Gateway resources sitting in the cluster that don’t actually serve any traffic.
Go through all existing Gateways and verify:
The referenced GatewayClass exists.
At least one valid Route (HTTPRoute, TCPRoute, etc.) is bound to it.
If both the GatewayClass or the attached Routes are missing, mark the Gateway as unused.
Utilize the ShowReason flag to indicate why the Gateway was considered unused.
NOTE: Since a Gateway can expose multiple listeners and attach multiple routes, the existence of at least one valid route/attachment should make the Gateway considered USED.
Examples
In the attached examples:
A Gateway referencing a non-existing GatewayClass.
The Gateway cannot be provisioned, hence should be considered UNUSED.
A Gateway with no routes attached.
The Gateway exists but does not route any traffic, hence should be considered UNUSED.
A Gateway with multiple listeners and only one valid attached HTTPRoute.
Even if some listeners/routes are missing, the Gateway as a whole should be considered USED.
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: web-gateway
spec:
gatewayClassName: non-existing-class
listeners:
- name: http
port: 80
protocol: HTTP
Describe the solution you'd like
$ kor gateways
Unused Gateways:
+---+------------+-----------------+--------------------------------------------+
| # | NAMESPACE | RESOURCE NAME | REASON |
+---+------------+-----------------+--------------------------------------------+
| 1 | default | gw-1 | Gateway references a non-existing class |
| 2 | prod | gw-2 | Gateway has no attached routes |
+---+------------+-----------------+--------------------------------------------+
Fature checklist
[ ] pkg/kor/gateways.go
[ ] pkg/kor/gateways_test.go
[ ] pkg/kor/create_test_resources.go
[ ] pkg/kor/all.go
[ ] pkg/kor/delete.go
[ ] pkg/kor/multi.go
[ ] pkg/kor/exceptions/gateways
[ ] cmd/kor/gateways.go
[ ] charts/kor/templates/role.yaml
[ ] README.md
Is your feature request related to a problem? Please describe.
Gateways can be created while referencing non-existing GatewayClasses or can exist without any attached Routes (HTTPRoute, TCPRoute, UDPRoute, etc.).
This can leave unused Gateway resources sitting in the cluster that don’t actually serve any traffic.
Go through all existing Gateways and verify:
The referenced GatewayClass exists.
At least one valid Route (HTTPRoute, TCPRoute, etc.) is bound to it.
If both the GatewayClass or the attached Routes are missing, mark the Gateway as unused.
Utilize the ShowReason flag to indicate why the Gateway was considered unused.
NOTE: Since a Gateway can expose multiple listeners and attach multiple routes, the existence of at least one valid route/attachment should make the Gateway considered USED.
Examples
In the attached examples:
A Gateway referencing a non-existing GatewayClass.
The Gateway cannot be provisioned, hence should be considered UNUSED.
A Gateway with no routes attached.
The Gateway exists but does not route any traffic, hence should be considered UNUSED.
A Gateway with multiple listeners and only one valid attached HTTPRoute.
Even if some listeners/routes are missing, the Gateway as a whole should be considered USED.
Describe the solution you'd like
Fature checklist
[ ] pkg/kor/gateways.go
[ ] pkg/kor/gateways_test.go
[ ] pkg/kor/create_test_resources.go
[ ] pkg/kor/all.go
[ ] pkg/kor/delete.go
[ ] pkg/kor/multi.go
[ ] pkg/kor/exceptions/gateways
[ ] cmd/kor/gateways.go
[ ] charts/kor/templates/role.yaml
[ ] README.md