Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable GRPCRoute Traffic + Remaining GRPCRoute Event Handling #350

Merged
merged 52 commits into from
Aug 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
beada24
Added route abstraction
Aug 4, 2023
bfdd085
Merge branch 'main' into 25
Aug 4, 2023
51cbb5e
Fixed some broken test logic
Aug 4, 2023
9f673c8
Fixed abstraction usage
Aug 4, 2023
e5c5939
Finalized initial abstraction
Aug 4, 2023
bf1b7fc
Added keys to unkeyed values
Aug 8, 2023
e6c0aaf
Switched to struct reference methods rather than value, Reverted usin…
Aug 8, 2023
cc5c1b8
Made abstracted constructs private
Aug 9, 2023
c8b117c
Fixed missing brackets
Aug 9, 2023
7fc63ea
Added GRPC Route Match Support
Aug 12, 2023
ffc9945
Switched to PathMatch for gRPC matches
Aug 14, 2023
c4b9dbf
Merge branch 'main' into 25
Aug 14, 2023
72565b4
Merge branch 'aws:main' into 25
xWink Aug 14, 2023
59d4152
Merge remote-tracking branch 'origin/25' into 25
Aug 14, 2023
bb4afc8
Merge branch 'main' into 25
Aug 16, 2023
dddbd66
Merge branch 'main' into 25
Aug 16, 2023
7fbd377
Added GPRCRoute CRD
Aug 16, 2023
88a8c76
Added GRPCRoute model building
Aug 16, 2023
974b679
Added test for method match on all grpc methods
Aug 16, 2023
7c84d19
Added fix for target group deletion
Aug 17, 2023
b56d552
Merge branch 'main' into 25
Aug 17, 2023
eac7c78
Merge branch 'main' into 25
Aug 17, 2023
eab6b41
Resolved merge conflicts from main
Aug 17, 2023
42bc17f
Added GRPCRoute controller and event handler
Aug 18, 2023
5419903
Merge branch 'main' into 25
Aug 18, 2023
8139ab1
Added vpclattice_mocks modification
Aug 18, 2023
39195aa
Add '-v 6' flag when running in dev mode
Aug 18, 2023
9ed57cc
Consolidated route event names
Aug 18, 2023
24d6849
Consolidated route controllers
Aug 19, 2023
cf36275
use gwlog instead of glog
Aug 19, 2023
6836ed8
Consolidate route event handlers
Aug 19, 2023
626907a
Removed unused function
Aug 19, 2023
7a90c5d
Removed unnecessary comments
Aug 19, 2023
608acfa
Merge branch 'main' into 25
Aug 21, 2023
ad6c346
Code and log cleanup
Aug 21, 2023
dacf189
Merge branch 'main' into 25
Aug 21, 2023
8508de1
Prevent target groups referenced by GRPCRoutes from becoming stale, S…
Aug 22, 2023
f738698
Merge branch 'main' into 25
Aug 22, 2023
3a6e000
clean up route files, service and gateway route usage
Aug 22, 2023
d8b2e73
Service import now supports GRPCRoutes and logs cleaned up
Aug 22, 2023
4962478
Set up greeter grpc route and server for traffic testing
Aug 22, 2023
272e401
Generified gateway event handler
Aug 23, 2023
bd8167c
Add gateway controller support for generic routes
Aug 23, 2023
e063c3c
Renamed greeter grpc yaml
Aug 23, 2023
1e6d73f
Fixed typo in backendRef
Aug 23, 2023
7d0fd26
Add mocks
Aug 23, 2023
b1019c3
Using go-based grpc server image
Aug 23, 2023
1d0254a
Merge branch 'main' into 25
Aug 25, 2023
7757763
Resolved merge conflicts
Aug 25, 2023
4a1e359
Addressed comments, added Equals tests
Aug 25, 2023
43c3294
Update grpc route backend ref port to service port
Aug 25, 2023
8b495ca
Revert to client_mocks from March 14, 2023
Aug 25, 2023
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
18 changes: 6 additions & 12 deletions cmd/aws-application-networking-k8s/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,20 +162,14 @@ func main() {
setupLog.Fatalf("route controller setup failed: %s", err)
}

serviceImportReconciler := controllers.NewServceImportReconciler(mgr.GetClient(), mgr.GetScheme(),
mgr.GetEventRecorderFor("ServiceImport"), finalizerManager, latticeDataStore)

if err = serviceImportReconciler.SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "ServiceImport")
os.Exit(1)
err = controllers.RegisterServiceImportController(ctrlLog.Named("service-import"), mgr, latticeDataStore, finalizerManager)
if err != nil {
xWink marked this conversation as resolved.
Show resolved Hide resolved
setupLog.Fatalf("serviceimport controller setup failed: %s", err)
}

serviceExportReconciler := controllers.NewServiceExportReconciler(cloud, mgr.GetClient(),
mgr.GetScheme(), mgr.GetEventRecorderFor("serviceExport"), finalizerManager, latticeDataStore)

if err = serviceExportReconciler.SetupWithManager(ctrlLog.Named("service-export"), mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "serviceExport")
os.Exit(1)
err = controllers.RegisterServiceExportController(ctrlLog.Named("service-export"), cloud, latticeDataStore, finalizerManager, mgr)
if err != nil {
setupLog.Fatalf("serviceexport controller setup failed: %s", err)
}

go latticestore.GetDefaultLatticeDataStore().ServeIntrospection()
Expand Down
26 changes: 11 additions & 15 deletions controllers/eventhandlers/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ package eventhandlers

import (
"context"

"github.com/golang/glog"
"github.com/aws/aws-application-networking-k8s/pkg/utils/gwlog"

corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/equality"
Expand All @@ -17,24 +16,26 @@ import (
)

type enqueueRequestsForEndpointsEvent struct {
log gwlog.Logger
client client.Client
}

func NewEnqueueRequestEndpointEvent(client client.Client) handler.EventHandler {
func NewEnqueueRequestEndpointEvent(log gwlog.Logger, client client.Client) handler.EventHandler {
return &enqueueRequestsForEndpointsEvent{
log: log,
client: client,
}
}

func (h *enqueueRequestsForEndpointsEvent) Create(e event.CreateEvent, queue workqueue.RateLimitingInterface) {
glog.V(6).Info("Event: endpoint create")
h.log.Info("Event: endpoint create")

epNew := e.Object.(*corev1.Endpoints)
h.enqueueImpactedService(queue, epNew)
}

func (h *enqueueRequestsForEndpointsEvent) Update(e event.UpdateEvent, queue workqueue.RateLimitingInterface) {
glog.V(6).Info("Event: endpoints update")
h.log.Info("Event: endpoints update")
epOld := e.ObjectOld.(*corev1.Endpoints)
epNew := e.ObjectNew.(*corev1.Endpoints)
if !equality.Semantic.DeepEqual(epOld.Subsets, epNew.Subsets) {
Expand All @@ -43,7 +44,7 @@ func (h *enqueueRequestsForEndpointsEvent) Update(e event.UpdateEvent, queue wor
}

func (h *enqueueRequestsForEndpointsEvent) Delete(e event.DeleteEvent, queue workqueue.RateLimitingInterface) {
glog.V(6).Infof("Event: endpoints delete")
h.log.Infof("Event: endpoints delete")
// service event handler handles this event here
}

Expand All @@ -52,18 +53,13 @@ func (h *enqueueRequestsForEndpointsEvent) Generic(e event.GenericEvent, queue w
}

func (h *enqueueRequestsForEndpointsEvent) enqueueImpactedService(queue workqueue.RateLimitingInterface, ep *corev1.Endpoints) {
glog.V(6).Infof("Event: enqueueImpactedService [%v]", ep)
h.log.Infof("Event: enqueueImpactedService for service name %s, namespace %s", ep.Name, ep.Namespace)

var targetIPList []string

// building a IP list
for _, endPoint := range ep.Subsets {

for _, address := range endPoint.Addresses {

targetIPList = append(targetIPList, address.IP)
}

}

svc := &corev1.Service{}
Expand All @@ -73,14 +69,14 @@ func (h *enqueueRequestsForEndpointsEvent) enqueueImpactedService(queue workqueu
}

if err := h.client.Get(context.TODO(), namespaceName, svc); err != nil {
glog.V(6).Infof("Event: enqueueImpactedService, service not found %v\n", err)
h.log.Infof("Event: enqueueImpactedService, service not found %v\n", err)
return
}

queue.Add(reconcile.Request{
NamespacedName: namespaceName,
})

glog.V(6).Infof("Finished enqueueImpactedService [%v] targetIPLIST[%v]\n", ep, targetIPList)

h.log.Infof("Finished enqueueImpactedService for service name %s, namespace %s targetIPLIST[%v]",
ep.Name, ep.Namespace, targetIPList)
}
50 changes: 28 additions & 22 deletions controllers/eventhandlers/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import (
"context"
"time"

"github.com/aws/aws-application-networking-k8s/pkg/model/core"
"github.com/aws/aws-application-networking-k8s/pkg/utils/gwlog"

"github.com/golang/glog"

"k8s.io/apimachinery/pkg/api/equality"
Expand All @@ -21,11 +24,13 @@ import (
)

type enqueueRequestsForGatewayEvent struct {
log gwlog.Logger
client client.Client
}

func NewEnqueueRequestGatewayEvent(client client.Client) handler.EventHandler {
func NewEnqueueRequestGatewayEvent(log gwlog.Logger, client client.Client) handler.EventHandler {
return &enqueueRequestsForGatewayEvent{
log: log,
client: client,
}
}
Expand All @@ -38,11 +43,11 @@ func (h *enqueueRequestsForGatewayEvent) Create(e event.CreateEvent, queue workq

// initialize transition time
gwNew.Status.Conditions[0].LastTransitionTime = ZeroTransitionTime
h.enqueueImpactedHTTPRoute(queue, gwNew)
h.enqueueImpactedRoutes(queue)
}

func (h *enqueueRequestsForGatewayEvent) Update(e event.UpdateEvent, queue workqueue.RateLimitingInterface) {
glog.V(6).Info("Gateway Update ")
h.log.Info("Gateway Update ")

gwOld := e.ObjectOld.(*gateway_api.Gateway)
gwNew := e.ObjectNew.(*gateway_api.Gateway)
Expand All @@ -52,7 +57,7 @@ func (h *enqueueRequestsForGatewayEvent) Update(e event.UpdateEvent, queue workq
gwOld.Spec, gwNew.Spec)
// initialize transition time
gwNew.Status.Conditions[0].LastTransitionTime = ZeroTransitionTime
h.enqueueImpactedHTTPRoute(queue, gwNew)
h.enqueueImpactedRoutes(queue)
}
}

Expand All @@ -64,32 +69,33 @@ func (h *enqueueRequestsForGatewayEvent) Generic(e event.GenericEvent, queue wor

}

func (h *enqueueRequestsForGatewayEvent) enqueueImpactedHTTPRoute(queue workqueue.RateLimitingInterface, gw *gateway_api.Gateway) {
httpRouteList := &gateway_api.HTTPRouteList{}

h.client.List(context.TODO(), httpRouteList)

for _, httpRoute := range httpRouteList.Items {
func (h *enqueueRequestsForGatewayEvent) enqueueImpactedRoutes(queue workqueue.RateLimitingInterface) {
routes, err := core.ListAllRoutes(context.TODO(), h.client)
if err != nil {
h.log.Errorf("Failed to list all routes, %s", err)
return
}
for _, route := range routes {

if len(httpRoute.Spec.ParentRefs) <= 0 {
glog.V(6).Infof("Ignore httpRoute no parentRefs %s", httpRoute.Name)
if len(route.Spec().ParentRefs()) <= 0 {
h.log.Infof("Ignore route no parentRefs %s", route.Name())
continue
}

// find the parent gw object
var gwNamespace = httpRoute.Namespace
if httpRoute.Spec.ParentRefs[0].Namespace != nil {
gwNamespace = string(*httpRoute.Spec.ParentRefs[0].Namespace)
var gwNamespace = route.Namespace()
if route.Spec().ParentRefs()[0].Namespace != nil {
gwNamespace = string(*route.Spec().ParentRefs()[0].Namespace)
}

gwName := types.NamespacedName{
Namespace: gwNamespace,
Name: string(httpRoute.Spec.ParentRefs[0].Name),
Name: string(route.Spec().ParentRefs()[0].Name),
}

gw := &gateway_api.Gateway{}

if err := h.client.Get(context.TODO(), gwName, gw); err != nil {
glog.V(6).Infof("Ignore HTTPRoute with unknown parentRef %s\n", httpRoute.Name)
h.log.Infof("Ignore Route with unknown parentRef %s", route.Name())
continue
}

Expand All @@ -101,16 +107,16 @@ func (h *enqueueRequestsForGatewayEvent) enqueueImpactedHTTPRoute(queue workqueu
}

if err := h.client.Get(context.TODO(), gwClassName, gwClass); err != nil {
glog.V(6).Infof("Ignore HTTPRoute with unknown Gateway %s \n", httpRoute.Name)
h.log.Infof("Ignore Route with unknown Gateway %s", route.Name())
continue
}

if gwClass.Spec.ControllerName == config.LatticeGatewayControllerName {
glog.V(2).Infof("Trigger HTTPRoute from Gateway event , httpRoute %s", httpRoute.Name)
glog.V(2).Infof("Trigger Route from Gateway event, route %s", route.Name())
queue.Add(reconcile.Request{
NamespacedName: types.NamespacedName{
Namespace: httpRoute.Namespace,
Name: httpRoute.Name,
Namespace: route.Namespace(),
Name: route.Name(),
},
})
}
Expand Down
Loading