@@ -2,8 +2,14 @@ package gateway
22
33import (
44 "context"
5+ "crypto/tls"
6+ "fmt"
7+ "google.golang.org/grpc"
8+ "google.golang.org/grpc/credentials"
9+ appsv1 "k8s.io/api/apps/v1"
510 corev1 "k8s.io/api/core/v1"
611 elbv2gw "sigs.k8s.io/aws-load-balancer-controller/apis/gateway/v1beta1"
12+ "sigs.k8s.io/aws-load-balancer-controller/test/e2e/gateway/grpc/echo"
713 "sigs.k8s.io/aws-load-balancer-controller/test/framework"
814 gwv1 "sigs.k8s.io/gateway-api/apis/v1"
915)
@@ -12,7 +18,7 @@ type ALBTestStack struct {
1218 albResourceStack * albResourceStack
1319}
1420
15- func (s * ALBTestStack ) Deploy (ctx context.Context , auxiliaryStack * auxiliaryResourceStack , f * framework.Framework , gwListeners []gwv1.Listener , httprs []* gwv1.HTTPRoute , lbConfSpec elbv2gw.LoadBalancerConfigurationSpec , tgConfSpec elbv2gw.TargetGroupConfigurationSpec , lrConfSpec elbv2gw.ListenerRuleConfigurationSpec , readinessGateEnabled bool ) error {
21+ func (s * ALBTestStack ) DeployHTTP (ctx context.Context , auxiliaryStack * auxiliaryResourceStack , f * framework.Framework , gwListeners []gwv1.Listener , httprs []* gwv1.HTTPRoute , lbConfSpec elbv2gw.LoadBalancerConfigurationSpec , tgConfSpec elbv2gw.TargetGroupConfigurationSpec , lrConfSpec elbv2gw.ListenerRuleConfigurationSpec , readinessGateEnabled bool ) error {
1622 if auxiliaryStack != nil {
1723 gwListeners = append (gwListeners , gwv1.Listener {
1824 Name : "other-ns" ,
@@ -23,15 +29,38 @@ func (s *ALBTestStack) Deploy(ctx context.Context, auxiliaryStack *auxiliaryReso
2329 httprs = append (httprs , buildOtherNsRefHttpRoute ("other-ns" , auxiliaryStack .ns ))
2430 }
2531
26- dp := buildDeploymentSpec (f .Options .TestImageRegistry )
2732 svc := buildServiceSpec ()
33+ tgc := buildTargetGroupConfig (defaultTgConfigName , tgConfSpec , svc )
34+ return s .deploy (ctx , f , gwListeners , httprs , []* gwv1.GRPCRoute {}, []* appsv1.Deployment {buildDeploymentSpec (f .Options .TestImageRegistry )}, []* corev1.Service {svc }, lbConfSpec , []* elbv2gw.TargetGroupConfiguration {tgc }, lrConfSpec , readinessGateEnabled )
35+ }
36+
37+ func (s * ALBTestStack ) DeployGRPC (ctx context.Context , f * framework.Framework , gwListeners []gwv1.Listener , grpcrs []* gwv1.GRPCRoute , lbConfSpec elbv2gw.LoadBalancerConfigurationSpec , tgConfSpec elbv2gw.TargetGroupConfigurationSpec , lrConfSpec elbv2gw.ListenerRuleConfigurationSpec , readinessGateEnabled bool ) error {
38+ labels := map [string ]string {
39+ "app.kubernetes.io/instance" : grpcDefaultName ,
40+ }
41+
42+ otherLabels := map [string ]string {
43+ "app.kubernetes.io/instance" : "other" ,
44+ }
45+
46+ svc := buildGRPCServiceSpec (grpcDefaultName , labels )
47+ dp := buildGRPCDeploymentSpec (grpcDefaultName , "Hello World" , labels )
48+ tgc := buildTargetGroupConfig (defaultTgConfigName , tgConfSpec , svc )
49+
50+ svcOther := buildGRPCServiceSpec (grpcDefaultName + "-other" , otherLabels )
51+ dpOther := buildGRPCDeploymentSpec (grpcDefaultName + "-other" , "Hello World - Other" , otherLabels )
52+ tgcOther := buildTargetGroupConfig (defaultTgConfigName + "-other" , tgConfSpec , svcOther )
53+
54+ return s .deploy (ctx , f , gwListeners , []* gwv1.HTTPRoute {}, grpcrs , []* appsv1.Deployment {dp , dpOther }, []* corev1.Service {svc , svcOther }, lbConfSpec , []* elbv2gw.TargetGroupConfiguration {tgc , tgcOther }, lrConfSpec , readinessGateEnabled )
55+ }
56+
57+ func (s * ALBTestStack ) deploy (ctx context.Context , f * framework.Framework , gwListeners []gwv1.Listener , httprs []* gwv1.HTTPRoute , grpcrs []* gwv1.GRPCRoute , dps []* appsv1.Deployment , svcs []* corev1.Service , lbConfSpec elbv2gw.LoadBalancerConfigurationSpec , tgcs []* elbv2gw.TargetGroupConfiguration , lrConfSpec elbv2gw.ListenerRuleConfigurationSpec , readinessGateEnabled bool ) error {
2858 gwc := buildGatewayClassSpec ("gateway.k8s.aws/alb" )
2959 gw := buildBasicGatewaySpec (gwc , gwListeners )
3060 lbc := buildLoadBalancerConfig (lbConfSpec )
31- tgc := buildTargetGroupConfig (defaultTgConfigName , tgConfSpec , svc )
3261 lrc := buildListenerRuleConfig (defaultLRConfigName , lrConfSpec )
3362
34- s .albResourceStack = newALBResourceStack (dp , svc , gwc , gw , lbc , tgc , lrc , httprs , "alb-gateway-e2e" , readinessGateEnabled )
63+ s .albResourceStack = newALBResourceStack (dps , svcs , gwc , gw , lbc , tgcs , lrc , httprs , grpcrs , "alb-gateway-e2e" , readinessGateEnabled )
3564
3665 return s .albResourceStack .Deploy (ctx , f )
3766}
@@ -58,3 +87,16 @@ func (s *ALBTestStack) GetWorkerNodes(ctx context.Context, f *framework.Framewor
5887 }
5988 return nodeList , nil
6089}
90+
91+ func generateGRPCClient (dnsName string ) (echo.EchoServiceClient , error ) {
92+ target := fmt .Sprintf ("%s:443" , dnsName )
93+ tlsConfig := & tls.Config {
94+ InsecureSkipVerify : true , // This skips all certificate verification, including expiry.
95+ }
96+
97+ conn , err := grpc .NewClient (target , grpc .WithTransportCredentials (credentials .NewTLS (tlsConfig )))
98+ if err != nil {
99+ return nil , err
100+ }
101+ return echo .NewEchoServiceClient (conn ), nil
102+ }
0 commit comments