Skip to content
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

Support cross resource group load balancer. #81054

Merged
merged 2 commits into from Aug 9, 2019

Conversation

@nilo19
Copy link
Contributor

commented Aug 7, 2019

/kind feature

What this PR does / why we need it:

Users want to reuse their existing LoadBalancer that are created in another resource group before the Kubernetes cluster is created.

Which issue(s) this PR fixes:

Fixes #78843

Does this PR introduce a user-facing change?:

Add a azure cloud configuration `LoadBalancerName` and `LoadBalancerResourceGroup` to allow the corresponding customizations of azure load balancer.
@k8s-ci-robot

This comment has been minimized.

Copy link
Contributor

commented Aug 7, 2019

Hi @nilo19. Thanks for your PR.

I'm waiting for a kubernetes 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/test-infra repository.

@nilo19

This comment has been minimized.

Copy link
Contributor Author

commented Aug 7, 2019

/sig azure

@feiskyer

This comment has been minimized.

Copy link
Member

commented Aug 7, 2019

/ok-to-test
/area provider/azure
/priority important-soon

return cloudprovider.DefaultLoadBalancerName(service)
}

func (az *Cloud) getLoadBalancerResourceGroup(service *v1.Service) string {
if rgName, found := service.Annotations[ServiceAnnotationLoadBalancerResourceGroup]; found && strings.TrimSpace(rgName) != "" {

This comment has been minimized.

Copy link
@feiskyer

feiskyer Aug 7, 2019

Member

let's add two new configuration options in Config:

LoadBalancerName string `json:"loadBalancerName,omitempty" yaml:"loadBalancerName,omitempty"`
LoadBalancerResourceGroup string `json:"loadBalancerResourceGroup,omitempty" yaml:"loadBalancerResourceGroup,omitempty"`

This comment has been minimized.

Copy link
@feiskyer

feiskyer Aug 7, 2019

Member

So, getLoadBalancerResourceGroup could be

if az.LoadBalancerResourceGroup != "" {
  return az.LoadBalancerResourceGroup
}

return az.ResourceGroup

This comment has been minimized.

Copy link
@feiskyer

feiskyer Aug 7, 2019

Member

same for loadBalancerName. But notice az.LoadBalancerName is only applied for defaultLBName (replace clusterName when generating the LB name).

@k8s-ci-robot k8s-ci-robot added size/M and removed size/L labels Aug 8, 2019

@feiskyer

This comment has been minimized.

Copy link
Member

commented Aug 8, 2019

/retest
/test pull-kubernetes-e2e-aks-engine-azure

@nilo19

This comment has been minimized.

Copy link
Contributor Author

commented Aug 8, 2019

/test pull-kubernetes-integration

@@ -304,7 +307,8 @@ func (az *Cloud) listLBWithRetry(service *v1.Service) ([]network.LoadBalancer, e
ctx, cancel := getContextWithCancel()
defer cancel()

allLBs, retryErr = az.LoadBalancerClient.List(ctx, az.ResourceGroup)
rgName := az.getLoadBalancerResourceGroup(service)
allLBs, retryErr = az.LoadBalancerClient.List(ctx, rgName)

This comment has been minimized.

Copy link
@feiskyer

feiskyer Aug 8, 2019

Member

Could you also fix this on L457 and L478:

az.LoadBalancerClient.Delete(ctx, az.ResourceGroup, lbName)
@@ -282,7 +284,8 @@ func (az *Cloud) ListLB(service *v1.Service) ([]network.LoadBalancer, error) {
ctx, cancel := getContextWithCancel()
defer cancel()

allLBs, err := az.LoadBalancerClient.List(ctx, az.ResourceGroup)
rgName := az.getLoadBalancerResourceGroup(service)
allLBs, err := az.LoadBalancerClient.List(ctx, rgName)
if err != nil {

This comment has been minimized.

Copy link
@feiskyer

feiskyer Aug 8, 2019

Member

Please also use rgName in logs below.

return cloudprovider.DefaultLoadBalancerName(service)
}

func (az *Cloud) getLoadBalancerResourceGroup(service *v1.Service) string {

This comment has been minimized.

Copy link
@feiskyer

feiskyer Aug 8, 2019

Member

param service is not used here, could we remove it?

// TODO: replace DefaultLoadBalancerName to generate more meaningful loadbalancer names.
if az.LoadBalancerName != "" {
return az.LoadBalancerName
}

This comment has been minimized.

Copy link
@feiskyer

feiskyer Aug 8, 2019

Member

Please rollback the changes in L222-L224. The name here is used for frontendipconfigurations, service UID should be used so that different services configurations won't be conflicted.

This comment has been minimized.

Copy link
@nilo19

nilo19 Aug 8, 2019

Author Contributor

Thanks for reviewing. The corresponding codes have been fixed.

@feiskyer

This comment has been minimized.

Copy link
Member

commented Aug 8, 2019

The resource group name on

lb, err := az.LoadBalancerClient.Get(ctx, az.ResourceGroup, key, "")
should also be changed to az.getLoadBalancerResourceGroup()

@nilo19 nilo19 force-pushed the nilo19:t-qini-cross_rg_lb branch from d282513 to 0500dfd Aug 8, 2019

@feiskyer

This comment has been minimized.

Copy link
Member

commented Aug 9, 2019

/test pull-kubernetes-e2e-aks-engine-azure

@feiskyer

This comment has been minimized.

Copy link
Member

commented Aug 9, 2019

@nilo19 nilo19 force-pushed the nilo19:t-qini-cross_rg_lb branch from 0500dfd to 659e857 Aug 9, 2019

@feiskyer
Copy link
Member

left a comment

/lgtm
/approve

@k8s-ci-robot

This comment has been minimized.

Copy link
Contributor

commented Aug 9, 2019

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: feiskyer, nilo19

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 merged commit 8527c74 into kubernetes:master Aug 9, 2019

22 of 23 checks passed

tide Not mergeable. Needs approved, lgtm labels.
Details
cla/linuxfoundation nilo19 authorized
Details
pull-kubernetes-bazel-build Job succeeded.
Details
pull-kubernetes-bazel-test Job succeeded.
Details
pull-kubernetes-conformance-image-test Skipped.
pull-kubernetes-cross Skipped.
pull-kubernetes-dependencies Job succeeded.
Details
pull-kubernetes-e2e-gce Job succeeded.
Details
pull-kubernetes-e2e-gce-100-performance Job succeeded.
Details
pull-kubernetes-e2e-gce-csi-serial Skipped.
pull-kubernetes-e2e-gce-device-plugin-gpu Job succeeded.
Details
pull-kubernetes-e2e-gce-iscsi Skipped.
pull-kubernetes-e2e-gce-iscsi-serial Skipped.
pull-kubernetes-e2e-gce-storage-slow Skipped.
pull-kubernetes-godeps Skipped.
pull-kubernetes-integration Job succeeded.
Details
pull-kubernetes-kubemark-e2e-gce-big Job succeeded.
Details
pull-kubernetes-local-e2e Skipped.
pull-kubernetes-node-e2e Job succeeded.
Details
pull-kubernetes-node-e2e-containerd Job succeeded.
Details
pull-kubernetes-typecheck Job succeeded.
Details
pull-kubernetes-verify Job succeeded.
Details
pull-publishing-bot-validate Skipped.

SIG Azure automation moved this from In progress to Done Aug 9, 2019

@k8s-ci-robot k8s-ci-robot added this to the v1.16 milestone Aug 9, 2019

@feiskyer

This comment has been minimized.

Copy link
Member

commented Aug 9, 2019

Thanks @nilo19. Please open a PR to update docs in cloud-provider-azure repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.