Skip to content

ylee/multi target group v2.8.1 #2

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

Closed
wants to merge 7 commits into from
Closed
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
2 changes: 1 addition & 1 deletion .go-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.21.9
1.22.3
2 changes: 1 addition & 1 deletion .ko.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defaultBaseImage: public.ecr.aws/eks-distro-build-tooling/eks-distro-minimal-base-nonroot:2023-09-06-1694026927.2
defaultBaseImage: public.ecr.aws/eks-distro-build-tooling/eks-distro-minimal-base-nonroot:2024-04-01-1711929684.2
builds:
- env:
- CGO_ENABLED=0
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
MAKEFILE_PATH = $(dir $(realpath -s $(firstword $(MAKEFILE_LIST))))

# Image URL to use all building/pushing image targets
IMG ?= public.ecr.aws/eks/aws-load-balancer-controller:v2.7.0
IMG ?= public.ecr.aws/eks/aws-load-balancer-controller:v2.8.1
# Image URL to use for builder stage in Docker build
GOLANG_VERSION ?= $(shell cat .go-version)
BUILD_IMAGE ?= public.ecr.aws/docker/library/golang:$(GOLANG_VERSION)
# Image URL to use for base layer in Docker build
BASE_IMAGE ?= public.ecr.aws/eks-distro-build-tooling/eks-distro-minimal-base-nonroot:2023-09-06-1694026927.2
BASE_IMAGE ?= public.ecr.aws/eks-distro-build-tooling/eks-distro-minimal-base-nonroot:2024-04-01-1711929684.2
IMG_PLATFORM ?= linux/amd64,linux/arm64
# ECR doesn't appear to support SPDX SBOM
IMG_SBOM ?= none
Expand Down Expand Up @@ -169,7 +169,7 @@ docs-preview: docs-dependencies

# publish the versioned docs using mkdocs mike util
docs-publish: docs-dependencies
pipenv run mike deploy v2.7 latest -p --update-aliases
pipenv run mike deploy v2.8 latest -p --update-aliases

# install dependencies needed to preview and publish docs
docs-dependencies:
Expand Down
2 changes: 1 addition & 1 deletion config/controller/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ kind: Kustomization
images:
- name: controller
newName: public.ecr.aws/eks/aws-load-balancer-controller
newTag: v2.7.0
newTag: v2.8.1
2 changes: 2 additions & 0 deletions config/crd/bases/elbv2.k8s.aws_ingressclassparams.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,13 @@ spec:
items:
type: string
type: array
x-kubernetes-list-type: atomic
required:
- key
- operator
type: object
type: array
x-kubernetes-list-type: atomic
matchLabels:
additionalProperties:
type: string
Expand Down
2 changes: 2 additions & 0 deletions config/crd/bases/elbv2.k8s.aws_targetgroupbindings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -342,11 +342,13 @@ spec:
items:
type: string
type: array
x-kubernetes-list-type: atomic
required:
- key
- operator
type: object
type: array
x-kubernetes-list-type: atomic
matchLabels:
additionalProperties:
type: string
Expand Down
1 change: 0 additions & 1 deletion config/webhook/manifests.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
Expand Down
9 changes: 5 additions & 4 deletions controllers/elbv2/eventhandlers/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package eventhandlers

import (
"context"

"github.com/go-logr/logr"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/equality"
Expand Down Expand Up @@ -32,13 +33,13 @@ type enqueueRequestsForEndpointsEvent struct {
}

// Create is called in response to an create event - e.g. Pod Creation.
func (h *enqueueRequestsForEndpointsEvent) Create(e event.CreateEvent, queue workqueue.RateLimitingInterface) {
func (h *enqueueRequestsForEndpointsEvent) Create(ctx context.Context, e event.CreateEvent, queue workqueue.RateLimitingInterface) {
epNew := e.Object.(*corev1.Endpoints)
h.enqueueImpactedTargetGroupBindings(queue, epNew)
}

// Update is called in response to an update event - e.g. Pod Updated.
func (h *enqueueRequestsForEndpointsEvent) Update(e event.UpdateEvent, queue workqueue.RateLimitingInterface) {
func (h *enqueueRequestsForEndpointsEvent) Update(ctx context.Context, e event.UpdateEvent, queue workqueue.RateLimitingInterface) {
epOld := e.ObjectOld.(*corev1.Endpoints)
epNew := e.ObjectNew.(*corev1.Endpoints)
if !equality.Semantic.DeepEqual(epOld.Subsets, epNew.Subsets) {
Expand All @@ -47,14 +48,14 @@ func (h *enqueueRequestsForEndpointsEvent) Update(e event.UpdateEvent, queue wor
}

// Delete is called in response to a delete event - e.g. Pod Deleted.
func (h *enqueueRequestsForEndpointsEvent) Delete(e event.DeleteEvent, queue workqueue.RateLimitingInterface) {
func (h *enqueueRequestsForEndpointsEvent) Delete(ctx context.Context, e event.DeleteEvent, queue workqueue.RateLimitingInterface) {
epOld := e.Object.(*corev1.Endpoints)
h.enqueueImpactedTargetGroupBindings(queue, epOld)
}

// Generic is called in response to an event of an unknown type or a synthetic event triggered as a cron or
// external trigger request - e.g. reconcile AutoScaling, or a WebHook.
func (h *enqueueRequestsForEndpointsEvent) Generic(event.GenericEvent, workqueue.RateLimitingInterface) {
func (h *enqueueRequestsForEndpointsEvent) Generic(context.Context, event.GenericEvent, workqueue.RateLimitingInterface) {
}

func (h *enqueueRequestsForEndpointsEvent) enqueueImpactedTargetGroupBindings(queue workqueue.RateLimitingInterface, ep *corev1.Endpoints) {
Expand Down
2 changes: 1 addition & 1 deletion controllers/elbv2/eventhandlers/endpoints_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func Test_enqueueRequestsForEndpointsEvent_enqueueImpactedTargetGroupBindings(t
k8sClient: k8sClient,
logger: logr.New(&log.NullLogSink{}),
}
queue := controllertest.Queue{Interface: workqueue.New()}
queue := &controllertest.Queue{Interface: workqueue.New()}
h.enqueueImpactedTargetGroupBindings(queue, tt.args.eps)
gotRequests := testutils.ExtractCTRLRequestsFromQueue(queue)
assert.True(t, cmp.Equal(tt.wantRequests, gotRequests),
Expand Down
16 changes: 8 additions & 8 deletions controllers/elbv2/eventhandlers/endpointslices.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,36 +36,36 @@ type enqueueRequestsForEndpointSlicesEvent struct {
}

// Create is called in response to an create event - e.g. EndpointSlice Creation.
func (h *enqueueRequestsForEndpointSlicesEvent) Create(e event.CreateEvent, queue workqueue.RateLimitingInterface) {
func (h *enqueueRequestsForEndpointSlicesEvent) Create(ctx context.Context, e event.CreateEvent, queue workqueue.RateLimitingInterface) {
epNew := e.Object.(*discv1.EndpointSlice)
h.logger.V(1).Info("Create event for EndpointSlices", "name", epNew.Name)
h.enqueueImpactedTargetGroupBindings(queue, epNew)
h.enqueueImpactedTargetGroupBindings(ctx, queue, epNew)
}

// Update is called in response to an update event - e.g. EndpointSlice Updated.
func (h *enqueueRequestsForEndpointSlicesEvent) Update(e event.UpdateEvent, queue workqueue.RateLimitingInterface) {
func (h *enqueueRequestsForEndpointSlicesEvent) Update(ctx context.Context, e event.UpdateEvent, queue workqueue.RateLimitingInterface) {
epOld := e.ObjectOld.(*discv1.EndpointSlice)
epNew := e.ObjectNew.(*discv1.EndpointSlice)
h.logger.V(1).Info("Update event for EndpointSlices", "name", epNew.Name)
if !equality.Semantic.DeepEqual(epOld.Ports, epNew.Ports) || !equality.Semantic.DeepEqual(epOld.Endpoints, epNew.Endpoints) {
h.logger.V(1).Info("Enqueue EndpointSlice", "name", epNew.Name)
h.enqueueImpactedTargetGroupBindings(queue, epNew)
h.enqueueImpactedTargetGroupBindings(ctx, queue, epNew)
}
}

// Delete is called in response to a delete event - e.g. EndpointSlice Deleted.
func (h *enqueueRequestsForEndpointSlicesEvent) Delete(e event.DeleteEvent, queue workqueue.RateLimitingInterface) {
func (h *enqueueRequestsForEndpointSlicesEvent) Delete(ctx context.Context, e event.DeleteEvent, queue workqueue.RateLimitingInterface) {
epOld := e.Object.(*discv1.EndpointSlice)
h.logger.V(1).Info("Deletion event for EndpointSlices", "name", epOld.Name)
h.enqueueImpactedTargetGroupBindings(queue, epOld)
h.enqueueImpactedTargetGroupBindings(ctx, queue, epOld)
}

// Generic is called in response to an event of an unknown type or a synthetic event triggered as a cron or
// external trigger request - e.g. reconcile AutoScaling, or a WebHook.
func (h *enqueueRequestsForEndpointSlicesEvent) Generic(event.GenericEvent, workqueue.RateLimitingInterface) {
func (h *enqueueRequestsForEndpointSlicesEvent) Generic(context.Context, event.GenericEvent, workqueue.RateLimitingInterface) {
}

func (h *enqueueRequestsForEndpointSlicesEvent) enqueueImpactedTargetGroupBindings(queue workqueue.RateLimitingInterface, epSlice *discv1.EndpointSlice) {
func (h *enqueueRequestsForEndpointSlicesEvent) enqueueImpactedTargetGroupBindings(ctx context.Context, queue workqueue.RateLimitingInterface, epSlice *discv1.EndpointSlice) {
tgbList := &elbv2api.TargetGroupBindingList{}
svcName, present := epSlice.Labels[svcNameLabel]
if !present {
Expand Down
4 changes: 2 additions & 2 deletions controllers/elbv2/eventhandlers/endpointslices_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ func Test_enqueueRequestsForEndpointSlicesEvent_enqueueImpactedTargetGroupBindin
k8sClient: k8sClient,
logger: logr.New(&log.NullLogSink{}),
}
queue := controllertest.Queue{Interface: workqueue.New()}
h.enqueueImpactedTargetGroupBindings(queue, tt.args.epslice)
queue := &controllertest.Queue{Interface: workqueue.New()}
h.enqueueImpactedTargetGroupBindings(context.Background(), queue, tt.args.epslice)
gotRequests := testutils.ExtractCTRLRequestsFromQueue(queue)
assert.True(t, cmp.Equal(tt.wantRequests, gotRequests),
"diff", cmp.Diff(tt.wantRequests, gotRequests))
Expand Down
16 changes: 8 additions & 8 deletions controllers/elbv2/eventhandlers/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,32 +31,32 @@ type enqueueRequestsForNodeEvent struct {
}

// Create is called in response to an create event - e.g. Pod Creation.
func (h *enqueueRequestsForNodeEvent) Create(e event.CreateEvent, queue workqueue.RateLimitingInterface) {
func (h *enqueueRequestsForNodeEvent) Create(ctx context.Context, e event.CreateEvent, queue workqueue.RateLimitingInterface) {
nodeNew := e.Object.(*corev1.Node)
h.enqueueImpactedTargetGroupBindings(queue, nil, nodeNew)
h.enqueueImpactedTargetGroupBindings(ctx, queue, nil, nodeNew)
}

// Update is called in response to an update event - e.g. Pod Updated.
func (h *enqueueRequestsForNodeEvent) Update(e event.UpdateEvent, queue workqueue.RateLimitingInterface) {
func (h *enqueueRequestsForNodeEvent) Update(ctx context.Context, e event.UpdateEvent, queue workqueue.RateLimitingInterface) {
nodeOld := e.ObjectOld.(*corev1.Node)
nodeNew := e.ObjectNew.(*corev1.Node)
h.enqueueImpactedTargetGroupBindings(queue, nodeOld, nodeNew)
h.enqueueImpactedTargetGroupBindings(ctx, queue, nodeOld, nodeNew)
}

// Delete is called in response to a delete event - e.g. Pod Deleted.
func (h *enqueueRequestsForNodeEvent) Delete(e event.DeleteEvent, queue workqueue.RateLimitingInterface) {
func (h *enqueueRequestsForNodeEvent) Delete(ctx context.Context, e event.DeleteEvent, queue workqueue.RateLimitingInterface) {
nodeOld := e.Object.(*corev1.Node)
h.enqueueImpactedTargetGroupBindings(queue, nodeOld, nil)
h.enqueueImpactedTargetGroupBindings(ctx, queue, nodeOld, nil)
}

// Generic is called in response to an event of an unknown type or a synthetic event triggered as a cron or
// external trigger request - e.g. reconcile AutoScaling, or a WebHook.
func (h *enqueueRequestsForNodeEvent) Generic(e event.GenericEvent, queue workqueue.RateLimitingInterface) {
func (h *enqueueRequestsForNodeEvent) Generic(context.Context, event.GenericEvent, workqueue.RateLimitingInterface) {
// nothing to do here
}

// enqueueImpactedTargetGroupBindings will enqueue all impacted TargetGroupBindings for node events.
func (h *enqueueRequestsForNodeEvent) enqueueImpactedTargetGroupBindings(queue workqueue.RateLimitingInterface, nodeOld *corev1.Node, nodeNew *corev1.Node) {
func (h *enqueueRequestsForNodeEvent) enqueueImpactedTargetGroupBindings(ctx context.Context, queue workqueue.RateLimitingInterface, nodeOld *corev1.Node, nodeNew *corev1.Node) {
var nodeKey types.NamespacedName
nodeOldSuitableAsTrafficProxy := false
nodeNewSuitableAsTrafficProxy := false
Expand Down
17 changes: 9 additions & 8 deletions controllers/elbv2/eventhandlers/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package eventhandlers

import (
"context"

"github.com/go-logr/logr"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/equality"
Expand Down Expand Up @@ -30,34 +31,34 @@ type enqueueRequestsForServiceEvent struct {
}

// Create is called in response to an create event - e.g. Pod Creation.
func (h *enqueueRequestsForServiceEvent) Create(e event.CreateEvent, queue workqueue.RateLimitingInterface) {
func (h *enqueueRequestsForServiceEvent) Create(ctx context.Context, e event.CreateEvent, queue workqueue.RateLimitingInterface) {
svcNew := e.Object.(*corev1.Service)
h.enqueueImpactedTargetGroupBindings(queue, svcNew)
h.enqueueImpactedTargetGroupBindings(ctx, queue, svcNew)
}

// Update is called in response to an update event - e.g. Pod Updated.
func (h *enqueueRequestsForServiceEvent) Update(e event.UpdateEvent, queue workqueue.RateLimitingInterface) {
func (h *enqueueRequestsForServiceEvent) Update(ctx context.Context, e event.UpdateEvent, queue workqueue.RateLimitingInterface) {
svcOld := e.ObjectOld.(*corev1.Service)
svcNew := e.ObjectNew.(*corev1.Service)
if !equality.Semantic.DeepEqual(svcOld.Spec.Ports, svcNew.Spec.Ports) {
h.enqueueImpactedTargetGroupBindings(queue, svcNew)
h.enqueueImpactedTargetGroupBindings(ctx, queue, svcNew)
}
}

// Delete is called in response to a delete event - e.g. Pod Deleted.
func (h *enqueueRequestsForServiceEvent) Delete(e event.DeleteEvent, queue workqueue.RateLimitingInterface) {
func (h *enqueueRequestsForServiceEvent) Delete(ctx context.Context, e event.DeleteEvent, queue workqueue.RateLimitingInterface) {
svcOld := e.Object.(*corev1.Service)
h.enqueueImpactedTargetGroupBindings(queue, svcOld)
h.enqueueImpactedTargetGroupBindings(ctx, queue, svcOld)
}

// Generic is called in response to an event of an unknown type or a synthetic event triggered as a cron or
// external trigger request - e.g. reconcile AutoScaling, or a WebHook.
func (h *enqueueRequestsForServiceEvent) Generic(e event.GenericEvent, queue workqueue.RateLimitingInterface) {
func (h *enqueueRequestsForServiceEvent) Generic(context.Context, event.GenericEvent, workqueue.RateLimitingInterface) {
// nothing to do here
}

// enqueueImpactedEndpointBindings will enqueue all impacted TargetGroupBindings for service events.
func (h *enqueueRequestsForServiceEvent) enqueueImpactedTargetGroupBindings(queue workqueue.RateLimitingInterface, svc *corev1.Service) {
func (h *enqueueRequestsForServiceEvent) enqueueImpactedTargetGroupBindings(ctx context.Context, queue workqueue.RateLimitingInterface, svc *corev1.Service) {
tgbList := &elbv2api.TargetGroupBindingList{}
if err := h.k8sClient.List(context.Background(), tgbList,
client.InNamespace(svc.Namespace),
Expand Down
4 changes: 2 additions & 2 deletions controllers/elbv2/eventhandlers/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ func Test_enqueueRequestsForServiceEvent_enqueueImpactedTargetGroupBindings(t *t
k8sClient: k8sClient,
logger: logr.New(&log.NullLogSink{}),
}
queue := controllertest.Queue{Interface: workqueue.New()}
h.enqueueImpactedTargetGroupBindings(queue, tt.args.svc)
queue := &controllertest.Queue{Interface: workqueue.New()}
h.enqueueImpactedTargetGroupBindings(context.Background(), queue, tt.args.svc)
gotRequests := testutils.ExtractCTRLRequestsFromQueue(queue)
assert.True(t, cmp.Equal(tt.wantRequests, gotRequests),
"diff", cmp.Diff(tt.wantRequests, gotRequests))
Expand Down
13 changes: 6 additions & 7 deletions controllers/elbv2/targetgroupbinding_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import (
"sigs.k8s.io/aws-load-balancer-controller/pkg/runtime"
"sigs.k8s.io/aws-load-balancer-controller/pkg/targetgroupbinding"
"sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/source"

"github.com/go-logr/logr"
ctrl "sigs.k8s.io/controller-runtime"
Expand Down Expand Up @@ -167,9 +166,9 @@ func (r *targetGroupBindingReconciler) SetupWithManager(ctx context.Context, mgr
return ctrl.NewControllerManagedBy(mgr).
For(&elbv2api.TargetGroupBinding{}).
Named(controllerName).
Watches(&source.Kind{Type: &corev1.Service{}}, svcEventHandler).
Watches(&source.Kind{Type: &discv1.EndpointSlice{}}, epSliceEventsHandler).
Watches(&source.Kind{Type: &corev1.Node{}}, nodeEventsHandler).
Watches(&corev1.Service{}, svcEventHandler).
Watches(&discv1.EndpointSlice{}, epSliceEventsHandler).
Watches(&corev1.Node{}, nodeEventsHandler).
WithOptions(controller.Options{
MaxConcurrentReconciles: r.maxConcurrentReconciles,
RateLimiter: workqueue.NewItemExponentialFailureRateLimiter(5*time.Millisecond, r.maxExponentialBackoffDelay)}).
Expand All @@ -180,9 +179,9 @@ func (r *targetGroupBindingReconciler) SetupWithManager(ctx context.Context, mgr
return ctrl.NewControllerManagedBy(mgr).
For(&elbv2api.TargetGroupBinding{}).
Named(controllerName).
Watches(&source.Kind{Type: &corev1.Service{}}, svcEventHandler).
Watches(&source.Kind{Type: &corev1.Endpoints{}}, epsEventsHandler).
Watches(&source.Kind{Type: &corev1.Node{}}, nodeEventsHandler).
Watches(&corev1.Service{}, svcEventHandler).
Watches(&corev1.Endpoints{}, epsEventsHandler).
Watches(&corev1.Node{}, nodeEventsHandler).
WithOptions(controller.Options{
MaxConcurrentReconciles: r.maxConcurrentReconciles,
RateLimiter: workqueue.NewItemExponentialFailureRateLimiter(5*time.Millisecond, r.maxExponentialBackoffDelay)}).
Expand Down
Loading
Loading