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

add lb backend by node ip; fix describe lb; #142

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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 Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# GitHub viewer defaults to 8, change with ?ts=4 in URL

GIT_REPOSITORY= github.com/yunify/qingcloud-cloud-controller-manager
IMG?= qingcloud/cloud-controller-manager:v1.4.19
IMG?= qingcloud/cloud-controller-manager:v1.4.20
#Debug level: 0, 1, 2 (1 true, 2 use bash)
DEBUG?= 0
DOCKERFILE?= deploy/Dockerfile
Expand Down
2 changes: 1 addition & 1 deletion pkg/executor/lb.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (q *QingCloudClient) GetLoadBalancerByName(name string) (*apis.LoadBalancer
Owner: &q.Config.UserID,
//> 0 时,会额外返回监听器的信息
// >= 2 时,会返回集群健康检查信息
Verbose: qcservice.Int(1),
Verbose: qcservice.Int(2),
}
output, err := q.LBService.DescribeLoadBalancers(input)
if err != nil && strings.Contains(err.Error(), "QingCloud Error: Code (1300)") {
Expand Down
11 changes: 11 additions & 0 deletions pkg/qingcloud/loadbalancer_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ func generateLoadBalancerBackends(nodes []*v1.Node, listener *apis.LoadBalancerL

for _, node := range nodes {
nodeName := nodeToInstanceIDs(node)
// ip := getIPStr(node)
backend := &apis.LoadBalancerBackend{
Spec: apis.LoadBalancerBackendSpec{
LoadBalancerListenerID: listener.Status.LoadBalancerListenerID,
Expand Down Expand Up @@ -595,3 +596,13 @@ func getDefaultBackendCount(nodes []*v1.Node) (backendCountResult int) {
}
return
}

// get node internal ip
func getIPStr(node *v1.Node) (ipStr string) {
for _, addr := range node.Status.Addresses {
if addr.Type == v1.NodeInternalIP {
return addr.Address
}
}
return
}