Skip to content

Conversation

shuqz
Copy link
Collaborator

@shuqz shuqz commented Apr 25, 2025

Issue

Description

add support for ServiceExternalTrafficPolicyLocal when ExternalTrafficPolicy is defined in Service Spec for NLB. To have default value for Local case, it needs to satisfy:

  1. targetType = Instance
  2. externalTrafficPolicy = Local
  3. load balancer type = NLB

Checklist

  • [✅] Added tests that cover your change (if possible)
  • [] Added/modified documentation as required (such as the README.md, or the docs directory)
  • [✅] Manually tested (changed in kind:Service YAML file)
    • test case 1: set externalTrafficPolicy: Cluster -> no difference, this is the default case
    • test case 2: set externalTrafficPolicy: Local and not specify healthCheckNodePort -> random number(range 30000-32767) is chosen for health check node port and other default values are taken
    • test case 3: set externalTrafficPolicy: Local and specify healthCheckNodePort -> healthCheckNodePort is chosen for health check node port and other default values are taken
    • test case 4: set externalTrafficPolicy: Local and specify healthCheckNodePort and under Type:NodePort -> get error " spec.healthCheckNodePort: Invalid value: 30001: may only be set when type is 'LoadBalancer' and externalTrafficPolicy is 'Local'"
  • [✅] Made sure the title of the PR is a good description that can go into the release notes

BONUS POINTS checklist: complete for good vibes and maybe prizes?! 🤯

  • Backfilled missing tests for code in same general area 🎉
  • Refactored something and made the world a better place 🌟

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Apr 25, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @shuqz. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Apr 25, 2025
@@ -515,6 +542,12 @@ func (builder *targetGroupBuilderImpl) buildTargetGroupHealthCheckPath(targetGro
return &builder.defaultHealthCheckPathGRPC
}

if targetGroupProps == nil || targetGroupProps.HealthCheckConfig == nil || targetGroupProps.HealthCheckConfig.HealthCheckPath == nil {
if builder.loadBalancerType == elbv2model.LoadBalancerTypeNetwork && isServiceExternalTrafficPolicyTypeLocal {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: isServiceExternalTrafficPolicyTypeLocal will never be true for application lb, so you can drop the nlb check.

if targetGroupProps == nil || targetGroupProps.HealthCheckConfig == nil || targetGroupProps.HealthCheckConfig.HealthCheckInterval == nil {
return builder.defaultHealthCheckInterval
return map[bool]int32{
Copy link
Collaborator

Choose a reason for hiding this comment

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

interesting pattern :)

Copy link
Collaborator

@zac-nixon zac-nixon left a comment

Choose a reason for hiding this comment

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

I was expecting this to as a new property in the TG config to fit the pattern of defining TG attributes in that CRD. But I think this is ok, and it's not a one-way door. We can add the TG prop at a later time.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: shuqz, zac-nixon

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 28, 2025
@zac-nixon
Copy link
Collaborator

/ok-to-test
/lgtm
/approved

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Apr 28, 2025
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 28, 2025
@k8s-ci-robot k8s-ci-robot merged commit cb59a3e into kubernetes-sigs:main Apr 28, 2025
5 checks passed
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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. 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.

3 participants