Skip to content

Conversation

kishorj
Copy link
Contributor

@kishorj kishorj commented May 13, 2021

Filter out redundant health check security group rules when the following conditions are met

  • health check and traffic ports are the same
  • preserve client IP is enabled
  • custom source ranges is not configured on the service resource, or 0.0.0.0/0 is allowed

In case of preserve client IP disabled, separate set of health check rules do not get added if traffic and health check ports are the same.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label May 13, 2021
@k8s-ci-robot k8s-ci-robot requested a review from M00nF1sh May 13, 2021 22:02
@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 13, 2021
@codecov-commenter
Copy link

Codecov Report

Merging #2006 (5303f59) into main (47b0ffb) will increase coverage by 0.10%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2006      +/-   ##
==========================================
+ Coverage   49.05%   49.15%   +0.10%     
==========================================
  Files         130      130              
  Lines        7008     7022      +14     
==========================================
+ Hits         3438     3452      +14     
  Misses       3292     3292              
  Partials      278      278              
Impacted Files Coverage Δ
pkg/service/model_build_target_group.go 84.22% <100.00%> (+0.72%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 47b0ffb...5303f59. Read the comment docs.

func (t *defaultModelBuildTask) buildHealthCheckNetworkingIngressRules(trafficSource, hcSource []elbv2model.NetworkingPeer, tgPort, hcPort intstr.IntOrString,
tgProtocol corev1.Protocol, preserveClientIP, customSoureRanges bool) []elbv2model.NetworkingIngressRule {
if tgProtocol != corev1.ProtocolUDP &&
(hcPort.String() == healthCheckPortTrafficPort || hcPort.IntValue() == tgPort.IntValue()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit:
hcPort.IntValue() == tgPort.IntValue this check is hacky.
If somehow in the future, both hcPort and tgPort is a string but not equal, this will evaluate to true.

ideally we should check hcPort's type.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

currently health check port is limited to int values. Will revisit this logic when we support named ports as well.

if !preserveClientIP {
return []elbv2model.NetworkingIngressRule{}
}
if !customSoureRanges {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for this version.
however, this becomes really complicated. we should refactor this logic here by some thing like compare CIDRs in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

once we have SG support for NLB, this wouldn't be a matter of concern.

Copy link
Collaborator

@M00nF1sh M00nF1sh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kishorj, M00nF1sh

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@M00nF1sh
Copy link
Collaborator

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 14, 2021
@k8s-ci-robot k8s-ci-robot merged commit 86ae453 into kubernetes-sigs:main May 14, 2021
@kishorj kishorj deleted the hc-rules branch May 29, 2021 01:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants