Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pkg/gateway/model_build_lattice_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ func (t *latticeServiceModelBuildTask) buildLatticeService(ctx context.Context)
routeType = core.GrpcRouteType
case *core.TLSRoute:
routeType = core.TlsRouteType
// VPC Lattice requires a custom domain name for TLS listeners
if len(t.route.Spec().Hostnames()) == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

In which scenario will the hostname will be nil ? Is this a user configuration that needs to be highlighted for customers in docs ?

return nil, fmt.Errorf("TLSRoute %s/%s must specify at least one hostname as VPC Lattice requires a custom domain name",
t.route.Namespace(), t.route.Name())
}
default:
return nil, fmt.Errorf("unsupported route type: %T", t.route)
}
Expand Down
27 changes: 27 additions & 0 deletions pkg/gateway/model_build_lattice_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
testclient "sigs.k8s.io/controller-runtime/pkg/client/fake"
gwv1 "sigs.k8s.io/gateway-api/apis/v1"
gwv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2"
)

func Test_LatticeServiceModelBuild(t *testing.T) {
Expand Down Expand Up @@ -403,6 +404,31 @@ func Test_LatticeServiceModelBuild(t *testing.T) {
ServiceNetworkNames: []string{vpcLatticeGateway.Name, "gateway2"},
},
},
{
name: "TLSRoute without hostname should fail",
wantIsDeleted: false,
wantErrIsNil: false,
gwClass: vpcLatticeGatewayClass,
gws: []gwv1.Gateway{
vpcLatticeGateway,
},
route: core.NewTLSRoute(gwv1alpha2.TLSRoute{
ObjectMeta: metav1.ObjectMeta{
Name: "service1",
Namespace: "default",
},
Spec: gwv1alpha2.TLSRouteSpec{
CommonRouteSpec: gwv1.CommonRouteSpec{
ParentRefs: []gwv1.ParentReference{
{
Name: gwv1.ObjectName(vpcLatticeGateway.Name),
Namespace: namespacePtr(vpcLatticeGateway.Namespace),
},
},
},
},
}),
},
{
name: "Multiple service networks with one different controller",
wantIsDeleted: false,
Expand Down Expand Up @@ -463,6 +489,7 @@ func Test_LatticeServiceModelBuild(t *testing.T) {
k8sSchema := runtime.NewScheme()
clientgoscheme.AddToScheme(k8sSchema)
gwv1.Install(k8sSchema)
gwv1alpha2.Install(k8sSchema)
k8sClient := testclient.NewClientBuilder().WithScheme(k8sSchema).Build()

assert.NoError(t, k8sClient.Create(ctx, tt.gwClass.DeepCopy()))
Expand Down
Loading