@@ -27,6 +27,8 @@ import (
27
27
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
28
28
)
29
29
30
+ const RouteBackendServiceKind = "Service"
31
+
30
32
// k8sWorkloadObjectFromInfo creates a Resource object from an Info object
31
33
func k8sWorkloadObjectFromInfo (info * resource.Info ) (* Resource , error ) {
32
34
var podSpecV1 * v1.PodTemplateSpec
@@ -205,6 +207,9 @@ func gatewayHTTPRouteFromInfo(info *resource.Info, toExpose servicesToExpose) er
205
207
rule := & routeObj .Spec .Rules [i ]
206
208
for j := range rule .BackendRefs {
207
209
backend := & rule .BackendRefs [j ]
210
+ if (backend .Kind != nil && string (* backend .Kind ) != RouteBackendServiceKind ) || backend .Port == nil {
211
+ continue // ignore backends which are not services and which do not specify a port
212
+ }
208
213
namespace := routeObj .Namespace
209
214
if backend .Namespace != nil {
210
215
namespace = string (* backend .Namespace )
@@ -227,6 +232,9 @@ func gatewayGRPCRouteFromInfo(info *resource.Info, toExpose servicesToExpose) er
227
232
rule := & routeObj .Spec .Rules [i ]
228
233
for j := range rule .BackendRefs {
229
234
backend := & rule .BackendRefs [j ]
235
+ if (backend .Kind != nil && string (* backend .Kind ) != RouteBackendServiceKind ) || backend .Port == nil {
236
+ continue // ignore backends which are not services and which do not specify a port
237
+ }
230
238
port := intstr .FromInt32 (int32 (* backend .Port ))
231
239
namespace := routeObj .Namespace
232
240
if backend .Namespace != nil {
0 commit comments