Skip to content

Rebase to v2.4.1 from upstream #5

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

Merged
merged 35 commits into from
Apr 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
2e8cf3f
feat(chart): add servicemonitor (#2335)
stevehipwell Feb 2, 2022
fe212ae
Merge tags from alb.ingress.kubernetes.io/tags (#2480)
oliviassss Feb 3, 2022
8b7f864
Adding support of ingressClassParams in helm charts (#2478)
haouc Feb 7, 2022
fbf568d
fix typo in annotations doc (#2482)
kishorj Feb 8, 2022
8761edb
add documentation for manage-backend-security-group-rules (#2486)
kishorj Feb 8, 2022
dce29ad
add support for loadBalancerClass (#2489)
kishorj Feb 8, 2022
996753b
make keepTLSSecret true by default (#2483)
kishorj Feb 8, 2022
6f4cbbf
add an option to disable SG rules management for NLB (#2481)
kishorj Feb 8, 2022
d34724c
Upgrade aws-sdk-go to 1.42.27
johngmyers Jan 5, 2022
8f96b0d
refactor: Use existing ELBv2 client
johngmyers Jan 10, 2022
cd4538b
Merge pull request #2500 from johngmyers/update-sdk
k8s-ci-robot Feb 10, 2022
8c50c9b
helm chart for v2.4.0 release (#2503)
kishorj Feb 15, 2022
00e1946
change IngressClassParams default name to alb (#2508)
kishorj Feb 15, 2022
1ebc0bd
doc updates for v2.4.0 (#2506)
kishorj Feb 16, 2022
8ba92d6
cut v2.4.0 release (#2507)
kishorj Feb 16, 2022
694a0b1
update docs-publish target to v2.4 (#2513)
kishorj Feb 16, 2022
7330bd1
Make e2e LB name test work with clusters that have . in the name
Feb 18, 2022
d9b4c5f
Renamed file for running e2e tests (#2510)
Feb 18, 2022
7670888
Merge pull request #2516 from olemarkus/sanitise-cluster-name
k8s-ci-robot Feb 19, 2022
76bd7e3
typo error (#2518)
nimboya Feb 23, 2022
9b65f3f
remove undesired certificates first
oliviassss Feb 28, 2022
53e6129
Merge pull request #2528 from oliviassss/update-certificates
k8s-ci-robot Mar 2, 2022
7baec17
Clarify cluster tag requirement (#2527)
adammw Mar 2, 2022
98fdad9
Webhook server use TLS 1.3 as minimum version
oliviassss Mar 11, 2022
7343672
Merge pull request #2547 from oliviassss/TLS_version
k8s-ci-robot Mar 14, 2022
8bd91f7
monitor secret resources ony if necessary (#2550)
kishorj Mar 15, 2022
779508f
add support for fail-open (#2546)
M00nF1sh Mar 15, 2022
a18ab63
Update pods with readinessGate as healthy for deleted TGB (#2524)
oliviassss Mar 15, 2022
bd49f0d
update iam permissions for TGB only configuration (#2554)
kishorj Mar 15, 2022
c4471de
cut v2.4.1 release (#2555)
kishorj Mar 16, 2022
aa32880
Merge remote-tracking branch 'fork/main' into rebase-2.4.1
arjunrn Apr 4, 2022
fa50f88
UPSTREAM: <carry>: Added downstream owners file and vendored dependen…
arjunrn Feb 7, 2022
93755fc
UPSTREAM: <carry>: Added Dockerfile used in Openshift builds
arjunrn Feb 9, 2022
f061bf6
UPSTREAM: <carry>: Change the base image from micro to minimal
arjunrn Mar 15, 2022
9f1a360
UPSTREAM: <drop>: Update vendored dependencies
arjunrn Apr 4, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:experimental

FROM --platform=${TARGETPLATFORM} public.ecr.aws/docker/library/golang:1.17.4 AS base
FROM --platform=${TARGETPLATFORM} public.ecr.aws/docker/library/golang:1.17.8 AS base
WORKDIR /workspace
# Copy the Go Modules manifests
COPY go.mod go.mod
Expand All @@ -25,7 +25,7 @@ RUN --mount=type=bind,target=. \
CGO_LDFLAGS="-Wl,-z,relro,-z,now" \
go build -buildmode=pie -tags 'osusergo,netgo,static_build' -ldflags="-s -w -linkmode=external -extldflags '-static-pie' -X ${VERSION_PKG}.GitVersion=${GIT_VERSION} -X ${VERSION_PKG}.GitCommit=${GIT_COMMIT} -X ${VERSION_PKG}.BuildDate=${BUILD_DATE}" -mod=readonly -a -o /out/controller main.go

FROM public.ecr.aws/eks-distro-build-tooling/eks-distro-minimal-base-nonroot:2021-12-01-1638322424 as bin-unix
FROM public.ecr.aws/eks-distro-build-tooling/eks-distro-minimal-base-nonroot:2022-03-09-1646784337.2 as bin-unix

COPY --from=build /out/controller /controller
ENTRYPOINT ["/controller"]
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
MAKEFILE_PATH = $(dir $(realpath -s $(firstword $(MAKEFILE_LIST))))

# Image URL to use all building/pushing image targets
IMG ?= amazon/aws-alb-ingress-controller:v2.3.1
IMG ?= amazon/aws-alb-ingress-controller:v2.4.1

CRD_OPTIONS ?= "crd:crdVersions=v1"

Expand Down Expand Up @@ -101,7 +101,7 @@ docs-preview: docs-dependencies

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

# install dependencies needed to preview and publish docs
docs-dependencies:
Expand Down
1 change: 1 addition & 0 deletions apis/elbv2/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions apis/elbv2/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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: amazon/aws-alb-ingress-controller
newTag: v2.3.1
newTag: v2.4.1
8 changes: 0 additions & 8 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,6 @@ rules:
verbs:
- patch
- update
- apiGroups:
- ""
resources:
- secrets
verbs:
- get
- list
- watch
- apiGroups:
- ""
resources:
Expand Down
52 changes: 39 additions & 13 deletions controllers/elbv2/eventhandlers/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,47 +55,54 @@ func (h *enqueueRequestsForNodeEvent) Generic(e event.GenericEvent, queue workqu
// nothing to do here
}

// enqueueImpactedEndpointBindings will enqueue all impacted TargetGroupBindings for node events.
// enqueueImpactedTargetGroupBindings will enqueue all impacted TargetGroupBindings for node events.
func (h *enqueueRequestsForNodeEvent) enqueueImpactedTargetGroupBindings(queue workqueue.RateLimitingInterface, nodeOld *corev1.Node, nodeNew *corev1.Node) {
var nodeKey types.NamespacedName
nodeOldIsReady := false
nodeNewIsReady := false
nodeOldSuitableAsTrafficProxy := false
nodeNewSuitableAsTrafficProxy := false
nodeOldReadyCondStatus := corev1.ConditionFalse
nodeNewReadyCondStatus := corev1.ConditionFalse
if nodeOld != nil {
nodeKey = k8s.NamespacedName(nodeOld)
nodeOldIsReady = k8s.IsNodeSuitableAsTrafficProxy(nodeOld)
nodeOldSuitableAsTrafficProxy = backend.IsNodeSuitableAsTrafficProxy(nodeOld)
if readyCond := k8s.GetNodeCondition(nodeOld, corev1.NodeReady); readyCond != nil {
nodeOldReadyCondStatus = readyCond.Status
}
}
if nodeNew != nil {
nodeKey = k8s.NamespacedName(nodeNew)
nodeNewIsReady = k8s.IsNodeSuitableAsTrafficProxy(nodeNew)
nodeNewSuitableAsTrafficProxy = backend.IsNodeSuitableAsTrafficProxy(nodeNew)
if readyCond := k8s.GetNodeCondition(nodeNew, corev1.NodeReady); readyCond != nil {
nodeNewReadyCondStatus = readyCond.Status
}
}

tgbList := &elbv2api.TargetGroupBindingList{}
if err := h.k8sClient.List(context.Background(), tgbList); err != nil {
h.logger.Error(err, "failed to fetch targetGroupBindings")
h.logger.Error(err, "[this should never happen] failed to fetch targetGroupBindings")
return
}

for _, tgb := range tgbList.Items {
if tgb.Spec.TargetType == nil || (*tgb.Spec.TargetType) != elbv2api.TargetTypeInstance {
continue
}

nodeSelector, err := backend.GetTrafficProxyNodeSelector(&tgb)
if err != nil {
h.logger.Error(err, "failed to get nodeSelector", "TargetGroupBinding", tgb)
return
continue
}

nodeOldIsTrafficProxy := false
nodeNewIsTrafficProxy := false
nodeOldSuitableAsTrafficProxyForTGB := false
nodeNewSuitableAsTrafficProxyForTGB := false
if nodeOld != nil {
nodeOldIsTrafficProxy = nodeOldIsReady && nodeSelector.Matches(labels.Set(nodeOld.Labels))
nodeOldSuitableAsTrafficProxyForTGB = nodeOldSuitableAsTrafficProxy && nodeSelector.Matches(labels.Set(nodeOld.Labels))
}
if nodeNew != nil {
nodeNewIsTrafficProxy = nodeNewIsReady && nodeSelector.Matches(labels.Set(nodeNew.Labels))
nodeNewSuitableAsTrafficProxyForTGB = nodeNewSuitableAsTrafficProxy && nodeSelector.Matches(labels.Set(nodeNew.Labels))
}

if nodeOldIsTrafficProxy != nodeNewIsTrafficProxy {
if h.shouldEnqueueTGBDueToNodeEvent(nodeOldSuitableAsTrafficProxyForTGB, nodeOldReadyCondStatus, nodeNewSuitableAsTrafficProxyForTGB, nodeNewReadyCondStatus) {
h.logger.V(1).Info("enqueue targetGroupBinding for node event",
"node", nodeKey,
"targetGroupBinding", k8s.NamespacedName(&tgb),
Expand All @@ -109,3 +116,22 @@ func (h *enqueueRequestsForNodeEvent) enqueueImpactedTargetGroupBindings(queue w
}
}
}

// shouldEnqueueTGBDueToNodeEvent checks whether a TGB should be queued due to node event.
func (h *enqueueRequestsForNodeEvent) shouldEnqueueTGBDueToNodeEvent(
nodeOldSuitableAsTrafficProxyForTGB bool, nodeOldReadyCondStatus corev1.ConditionStatus,
nodeNewSuitableAsTrafficProxyForTGB bool, nodeNewReadyCondStatus corev1.ConditionStatus) bool {
if nodeOldSuitableAsTrafficProxyForTGB == false && nodeNewSuitableAsTrafficProxyForTGB == false {
return false
}
if nodeOldSuitableAsTrafficProxyForTGB == true && nodeNewSuitableAsTrafficProxyForTGB == true {
return nodeOldReadyCondStatus != nodeNewReadyCondStatus
}
if nodeOldSuitableAsTrafficProxyForTGB == true && nodeNewSuitableAsTrafficProxyForTGB == false {
return nodeOldReadyCondStatus != corev1.ConditionFalse
}
if nodeOldSuitableAsTrafficProxyForTGB == false && nodeNewSuitableAsTrafficProxyForTGB == true {
return nodeNewReadyCondStatus != corev1.ConditionFalse
}
return false
}
170 changes: 170 additions & 0 deletions controllers/elbv2/eventhandlers/node_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
package eventhandlers

import (
"github.com/stretchr/testify/assert"
corev1 "k8s.io/api/core/v1"
"testing"
)

func Test_enqueueRequestsForNodeEvent_shouldEnqueueTGBDueToNodeEvent(t *testing.T) {
type args struct {
nodeOldSuitableAsTrafficProxyForTGB bool
nodeOldReadyCondStatus corev1.ConditionStatus
nodeNewSuitableAsTrafficProxyForTGB bool
nodeNewReadyCondStatus corev1.ConditionStatus
}
tests := []struct {
name string
args args
want bool
}{
{
name: "suitable node changed from ready to notReady",
args: args{
nodeOldSuitableAsTrafficProxyForTGB: true,
nodeOldReadyCondStatus: corev1.ConditionTrue,
nodeNewSuitableAsTrafficProxyForTGB: true,
nodeNewReadyCondStatus: corev1.ConditionFalse,
},
want: true,
},
{
name: "suitable node changed from ready to unknown",
args: args{
nodeOldSuitableAsTrafficProxyForTGB: true,
nodeOldReadyCondStatus: corev1.ConditionTrue,
nodeNewSuitableAsTrafficProxyForTGB: true,
nodeNewReadyCondStatus: corev1.ConditionUnknown,
},
want: true,
},
{
name: "suitable node changed from notReady to ready",
args: args{
nodeOldSuitableAsTrafficProxyForTGB: true,
nodeOldReadyCondStatus: corev1.ConditionFalse,
nodeNewSuitableAsTrafficProxyForTGB: true,
nodeNewReadyCondStatus: corev1.ConditionTrue,
},
want: true,
},
{
name: "suitable node changed from notReady to unknown",
args: args{
nodeOldSuitableAsTrafficProxyForTGB: true,
nodeOldReadyCondStatus: corev1.ConditionFalse,
nodeNewSuitableAsTrafficProxyForTGB: true,
nodeNewReadyCondStatus: corev1.ConditionUnknown,
},
want: true,
},
{
name: "suitable node changed from unknown to ready",
args: args{
nodeOldSuitableAsTrafficProxyForTGB: true,
nodeOldReadyCondStatus: corev1.ConditionUnknown,
nodeNewSuitableAsTrafficProxyForTGB: true,
nodeNewReadyCondStatus: corev1.ConditionTrue,
},
want: true,
},
{
name: "suitable node changed from unknown to notReady",
args: args{
nodeOldSuitableAsTrafficProxyForTGB: true,
nodeOldReadyCondStatus: corev1.ConditionUnknown,
nodeNewSuitableAsTrafficProxyForTGB: true,
nodeNewReadyCondStatus: corev1.ConditionFalse,
},
want: true,
},
{
name: "suitable node remains ready",
args: args{
nodeOldSuitableAsTrafficProxyForTGB: true,
nodeOldReadyCondStatus: corev1.ConditionTrue,
nodeNewSuitableAsTrafficProxyForTGB: true,
nodeNewReadyCondStatus: corev1.ConditionTrue,
},
want: false,
},
{
name: "suitable node remains notReady",
args: args{
nodeOldSuitableAsTrafficProxyForTGB: true,
nodeOldReadyCondStatus: corev1.ConditionFalse,
nodeNewSuitableAsTrafficProxyForTGB: true,
nodeNewReadyCondStatus: corev1.ConditionFalse,
},
want: false,
},
{
name: "suitable node remains unknown",
args: args{
nodeOldSuitableAsTrafficProxyForTGB: true,
nodeOldReadyCondStatus: corev1.ConditionUnknown,
nodeNewSuitableAsTrafficProxyForTGB: true,
nodeNewReadyCondStatus: corev1.ConditionUnknown,
},
want: false,
},
{
name: "non-suitable node changed from ready to notReady",
args: args{
nodeOldSuitableAsTrafficProxyForTGB: false,
nodeOldReadyCondStatus: corev1.ConditionTrue,
nodeNewSuitableAsTrafficProxyForTGB: false,
nodeNewReadyCondStatus: corev1.ConditionFalse,
},
want: false,
},
{
name: "node became suitable while remains ready",
args: args{
nodeOldSuitableAsTrafficProxyForTGB: false,
nodeOldReadyCondStatus: corev1.ConditionTrue,
nodeNewSuitableAsTrafficProxyForTGB: true,
nodeNewReadyCondStatus: corev1.ConditionTrue,
},
want: true,
},
{
name: "node became suitable while remains notReady",
args: args{
nodeOldSuitableAsTrafficProxyForTGB: false,
nodeOldReadyCondStatus: corev1.ConditionFalse,
nodeNewSuitableAsTrafficProxyForTGB: true,
nodeNewReadyCondStatus: corev1.ConditionFalse,
},
want: false,
},
{
name: "node became non-suitable while remains ready",
args: args{
nodeOldSuitableAsTrafficProxyForTGB: true,
nodeOldReadyCondStatus: corev1.ConditionTrue,
nodeNewSuitableAsTrafficProxyForTGB: false,
nodeNewReadyCondStatus: corev1.ConditionTrue,
},
want: true,
},
{
name: "node became non-suitable while remains notReady",
args: args{
nodeOldSuitableAsTrafficProxyForTGB: true,
nodeOldReadyCondStatus: corev1.ConditionFalse,
nodeNewSuitableAsTrafficProxyForTGB: false,
nodeNewReadyCondStatus: corev1.ConditionFalse,
},
want: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
h := &enqueueRequestsForNodeEvent{}
got := h.shouldEnqueueTGBDueToNodeEvent(tt.args.nodeOldSuitableAsTrafficProxyForTGB, tt.args.nodeOldReadyCondStatus,
tt.args.nodeNewSuitableAsTrafficProxyForTGB, tt.args.nodeNewReadyCondStatus)
assert.Equal(t, tt.want, got)
})
}
}
1 change: 0 additions & 1 deletion controllers/elbv2/targetgroupbinding_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ type targetGroupBindingReconciler struct {
// +kubebuilder:rbac:groups="",resources=pods/status,verbs=update;patch
// +kubebuilder:rbac:groups="",resources=nodes,verbs=get;list;watch
// +kubebuilder:rbac:groups="",resources=endpoints,verbs=get;list;watch
// +kubebuilder:rbac:groups="",resources=secrets,verbs=get;list;watch
// +kubebuilder:rbac:groups="",resources=namespaces,verbs=get;list;watch
// +kubebuilder:rbac:groups="",resources=events,verbs=create;patch
// +kubebuilder:rbac:groups="discovery.k8s.io",resources=endpointslices,verbs=get;list;watch
Expand Down
3 changes: 2 additions & 1 deletion controllers/ingress/eventhandlers/secret_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ func (h *enqueueRequestsForSecretEvent) Delete(e event.DeleteEvent, _ workqueue.
}

func (h *enqueueRequestsForSecretEvent) Generic(e event.GenericEvent, _ workqueue.RateLimitingInterface) {
// we don't have any generic event for secrets.
secretObj := e.Object.(*corev1.Secret)
h.enqueueImpactedObjects(secretObj)
}

func (h *enqueueRequestsForSecretEvent) enqueueImpactedObjects(secret *corev1.Secret) {
Expand Down
Loading