Skip to content

Commit

Permalink
Use EndpointSlice instead of Endpoints for gateway2 controller and pr…
Browse files Browse the repository at this point in the history
…oxy_syncer

Signed-off-by: Daneyon Hansen <[email protected]>
  • Loading branch information
danehans committed Nov 11, 2024
1 parent 4a94748 commit 34fe9c8
Show file tree
Hide file tree
Showing 9 changed files with 503 additions and 201 deletions.
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1242,9 +1242,8 @@ $(TEST_ASSET_DIR)/conformance/conformance_test.go:

CONFORMANCE_SUPPORTED_FEATURES ?= -supported-features=Gateway,ReferenceGrant,HTTPRoute,HTTPRouteQueryParamMatching,HTTPRouteMethodMatching,HTTPRouteResponseHeaderModification,HTTPRoutePortRedirect,HTTPRouteHostRewrite,HTTPRouteSchemeRedirect,HTTPRoutePathRedirect,HTTPRouteHostRewrite,HTTPRoutePathRewrite,HTTPRouteRequestMirror
CONFORMANCE_SUPPORTED_PROFILES ?= -conformance-profiles=GATEWAY-HTTP
CONFORMANCE_SKIP_TESTS ?= -skip-tests=HTTPRouteServiceTypes
CONFORMANCE_REPORT_ARGS ?= -report-output=$(TEST_ASSET_DIR)/conformance/$(VERSION)-report.yaml -organization=solo.io -project=gloo-gateway -version=$(VERSION) -url=github.com/solo-io/gloo -contact=github.com/solo-io/gloo/issues/new/choose
CONFORMANCE_ARGS := -gateway-class=gloo-gateway $(CONFORMANCE_SKIP_TESTS) $(CONFORMANCE_SUPPORTED_FEATURES) $(CONFORMANCE_SUPPORTED_PROFILES) $(CONFORMANCE_REPORT_ARGS)
CONFORMANCE_ARGS := -gateway-class=gloo-gateway $(CONFORMANCE_SUPPORTED_FEATURES) $(CONFORMANCE_SUPPORTED_PROFILES) $(CONFORMANCE_REPORT_ARGS)

.PHONY: conformance ## Run the conformance test suite
conformance: $(TEST_ASSET_DIR)/conformance/conformance_test.go
Expand Down
6 changes: 6 additions & 0 deletions changelog/v1.18.0-beta34/issue_6910.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
changelog:
- type: FIX
issueLink: https://github.com/solo-io/solo-projects/issues/6910
resolvesIssue: true
description: >-
Updates the gateway2 project to use EndpointSlice instead of Endpoints for creating upstream endpoints.
2 changes: 2 additions & 0 deletions pkg/schemes/scheme.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
ratelimitv1alpha1 "github.com/solo-io/solo-apis/pkg/api/ratelimit.solo.io/v1alpha1"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
discoveryv1 "k8s.io/api/discovery/v1"
"k8s.io/apimachinery/pkg/runtime"
apiv1 "sigs.k8s.io/gateway-api/apis/v1"
apiv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1"
Expand All @@ -24,6 +25,7 @@ var SchemeBuilder = runtime.SchemeBuilder{
// Kubernetes Core resources
corev1.AddToScheme,
appsv1.AddToScheme,
discoveryv1.AddToScheme,

// Solo Kubernetes Gateway API resources
sologatewayv1alpha1.AddToScheme,
Expand Down
11 changes: 6 additions & 5 deletions projects/gateway2/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"

corev1 "k8s.io/api/core/v1"
discoveryv1 "k8s.io/api/discovery/v1"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
Expand Down Expand Up @@ -80,7 +81,7 @@ func NewBaseGatewayController(ctx context.Context, cfg GatewayConfig) error {
controllerBuilder.watchVirtualHostOptions,
controllerBuilder.watchUpstreams,
controllerBuilder.watchServices,
controllerBuilder.watchEndpoints,
controllerBuilder.watchEndpointSlices,
controllerBuilder.watchPods,
controllerBuilder.watchSecrets,
controllerBuilder.addIndexes,
Expand Down Expand Up @@ -344,10 +345,10 @@ func (c *controllerBuilder) watchPods(ctx context.Context) error {
Complete(reconcile.Func(c.reconciler.ReconcilePods))
}

func (c *controllerBuilder) watchEndpoints(ctx context.Context) error {
func (c *controllerBuilder) watchEndpointSlices(ctx context.Context) error {
return ctrl.NewControllerManagedBy(c.cfg.Mgr).
For(&corev1.Endpoints{}).
Complete(reconcile.Func(c.reconciler.ReconcileEndpoints))
For(&discoveryv1.EndpointSlice{}).
Complete(reconcile.Func(c.reconciler.ReconcileEndpointSlices))
}

func (c *controllerBuilder) watchSecrets(ctx context.Context) error {
Expand Down Expand Up @@ -417,7 +418,7 @@ func (r *controllerReconciler) ReconcilePods(ctx context.Context, req ctrl.Reque
return ctrl.Result{}, nil
}

func (r *controllerReconciler) ReconcileEndpoints(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
func (r *controllerReconciler) ReconcileEndpointSlices(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
// eventually reconcile only effected listeners etc
r.kick(ctx)
return ctrl.Result{}, nil
Expand Down
17 changes: 10 additions & 7 deletions projects/gateway2/proxy_syncer/cla_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package proxy_syncer_test

import (
"context"
"testing"

corev3 "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
Expand All @@ -18,6 +19,8 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

var ctx = context.Background()

func TestTransformsEndpoint(t *testing.T) {
g := gomega.NewWithT(t)
us := UpstreamWrapper{
Expand All @@ -29,7 +32,7 @@ func TestTransformsEndpoint(t *testing.T) {
},
}
efu := NewEndpointsForUpstream(us, nil)
efu.Add(krtcollections.PodLocality{}, EndpointWithMd{
efu.Add(ctx, krtcollections.PodLocality{}, EndpointWithMd{
LbEndpoint: &endpointv3.LbEndpoint{
HostIdentifier: &endpointv3.LbEndpoint_Endpoint{
Endpoint: &endpointv3.Endpoint{
Expand Down Expand Up @@ -60,7 +63,7 @@ func TestTransformsEndpointsWithLocality(t *testing.T) {
},
}
efu := NewEndpointsForUpstream(us, nil)
efu.Add(krtcollections.PodLocality{Region: "R1"}, EndpointWithMd{
efu.Add(ctx, krtcollections.PodLocality{Region: "R1"}, EndpointWithMd{
LbEndpoint: &endpointv3.LbEndpoint{
HostIdentifier: &endpointv3.LbEndpoint_Endpoint{
Endpoint: &endpointv3.Endpoint{
Expand All @@ -72,7 +75,7 @@ func TestTransformsEndpointsWithLocality(t *testing.T) {
},
EndpointMd: EndpointMetadata{},
})
efu.Add(krtcollections.PodLocality{Region: "R2"}, EndpointWithMd{
efu.Add(ctx, krtcollections.PodLocality{Region: "R2"}, EndpointWithMd{
LbEndpoint: &endpointv3.LbEndpoint{
HostIdentifier: &endpointv3.LbEndpoint_Endpoint{
Endpoint: &endpointv3.Endpoint{
Expand Down Expand Up @@ -107,7 +110,7 @@ func TestTranslatesDestrulesFailoverPriority(t *testing.T) {
},
}
efu := NewEndpointsForUpstream(us, nil)
efu.Add(krtcollections.PodLocality{Region: "R1"}, EndpointWithMd{
efu.Add(ctx, krtcollections.PodLocality{Region: "R1"}, EndpointWithMd{
LbEndpoint: &endpointv3.LbEndpoint{
HostIdentifier: &endpointv3.LbEndpoint_Endpoint{
Endpoint: &endpointv3.Endpoint{
Expand All @@ -121,7 +124,7 @@ func TestTranslatesDestrulesFailoverPriority(t *testing.T) {
Labels: map[string]string{corev1.LabelTopologyRegion: "R1"},
},
})
efu.Add(krtcollections.PodLocality{Region: "R2"}, EndpointWithMd{
efu.Add(ctx, krtcollections.PodLocality{Region: "R2"}, EndpointWithMd{
LbEndpoint: &endpointv3.LbEndpoint{
HostIdentifier: &endpointv3.LbEndpoint_Endpoint{
Endpoint: &endpointv3.Endpoint{
Expand Down Expand Up @@ -197,7 +200,7 @@ func TestTranslatesDestrulesFailover(t *testing.T) {
},
}
efu := NewEndpointsForUpstream(us, nil)
efu.Add(krtcollections.PodLocality{Region: "R1"}, EndpointWithMd{
efu.Add(ctx, krtcollections.PodLocality{Region: "R1"}, EndpointWithMd{
LbEndpoint: &endpointv3.LbEndpoint{
HostIdentifier: &endpointv3.LbEndpoint_Endpoint{
Endpoint: &endpointv3.Endpoint{
Expand All @@ -211,7 +214,7 @@ func TestTranslatesDestrulesFailover(t *testing.T) {
Labels: map[string]string{corev1.LabelTopologyRegion: "R1"},
},
})
efu.Add(krtcollections.PodLocality{Region: "R2"}, EndpointWithMd{
efu.Add(ctx, krtcollections.PodLocality{Region: "R2"}, EndpointWithMd{
LbEndpoint: &endpointv3.LbEndpoint{
HostIdentifier: &endpointv3.LbEndpoint_Endpoint{
Endpoint: &endpointv3.Endpoint{
Expand Down
Loading

0 comments on commit 34fe9c8

Please sign in to comment.