Skip to content

Commit 92e9cd8

Browse files
Merge pull request #143 from qiangzii/master
add plg support for create lb
2 parents cd36e18 + 29b663b commit 92e9cd8

7 files changed

Lines changed: 15 additions & 4 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# GitHub viewer defaults to 8, change with ?ts=4 in URL
33

44
GIT_REPOSITORY= github.com/yunify/qingcloud-cloud-controller-manager
5-
IMG?= qingcloud/cloud-controller-manager:v1.4.20
5+
IMG?= qingcloud/cloud-controller-manager:v1.4.21
66
#Debug level: 0, 1, 2 (1 true, 2 use bash)
77
DEBUG?= 0
88
DOCKERFILE?= deploy/Dockerfile

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.19
55
require (
66
github.com/davecgh/go-spew v1.1.1
77
github.com/spf13/pflag v1.0.5
8-
github.com/yunify/qingcloud-sdk-go v0.0.0-20250120063512-895f1d8507aa
8+
github.com/yunify/qingcloud-sdk-go v0.0.0-20250417083958-b5f7eb82df62
99
gopkg.in/yaml.v2 v2.4.0
1010
k8s.io/api v0.21.1
1111
k8s.io/apimachinery v0.21.1

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,8 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de
382382
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
383383
github.com/yunify/qingcloud-sdk-go v0.0.0-20250120063512-895f1d8507aa h1:AJ2wQoxVo8QmwVI3lJFjf0eEwmToHBzfLBRf/rGEMPg=
384384
github.com/yunify/qingcloud-sdk-go v0.0.0-20250120063512-895f1d8507aa/go.mod h1:OfwXDPSOiv0Si+1iyH8+JDPPApt73Em03muEf9iKM+c=
385+
github.com/yunify/qingcloud-sdk-go v0.0.0-20250417083958-b5f7eb82df62 h1:iMjV/kc1SRvWXK/84wzi08yYTtgatr9aKRvBW+NzhZU=
386+
github.com/yunify/qingcloud-sdk-go v0.0.0-20250417083958-b5f7eb82df62/go.mod h1:OfwXDPSOiv0Si+1iyH8+JDPPApt73Em03muEf9iKM+c=
385387
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
386388
go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
387389
go.etcd.io/bbolt v1.3.5 h1:XAzx9gjCb0Rxj7EoqcClPD1d5ZBxZJk0jbuoPHenBt0=

pkg/apis/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ type LoadBalancerSpec struct {
3737
VxNetID *string `json:"vxnet_id" name:"vxnet_id"`
3838

3939
SecurityGroups *string `json:"securityGroups" name:"securityGroups"`
40+
PlaceGroupID *string `json:"place_group_id" name:"place_group_id"`
4041
}
4142

4243
type LoadBalancerStatus struct {

pkg/executor/lb.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ func (q *QingCloudClient) CreateLB(input *apis.LoadBalancer) (*apis.LoadBalancer
168168
NodeCount: input.Spec.NodeCount,
169169
VxNet: input.Spec.VxNetID,
170170
SecurityGroup: input.Spec.SecurityGroups,
171+
PlaceGroupID: input.Spec.PlaceGroupID,
171172
}
172173
if len(input.Spec.PrivateIPs) > 0 {
173174
inputLB.PrivateIP = input.Spec.PrivateIPs[0]

pkg/qingcloud/annotations.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ type LoadBalancerConfig struct {
109109
LoadBalancerType *int
110110
NodeCount *int
111111
InternalIP *string
112+
PlaceGroupID *string
112113

113114
//listener attrs
114115
healthyCheckMethod *string
@@ -183,6 +184,10 @@ func (qc *QingCloud) ParseServiceLBConfig(cluster string, service *v1.Service) (
183184
if internalReuseID, ok := annotation[ServiceAnnotationLoadBalancerInternalReuseID]; ok {
184185
config.InternalReuseID = &internalReuseID
185186
}
187+
//plg
188+
if qc.Config.PlaceGroupID != "" {
189+
config.PlaceGroupID = qcservice.String(qc.Config.PlaceGroupID)
190+
}
186191

187192
//listener annotation
188193
if healthyCheckMethod, ok := annotation[ServiceAnnotationListenerHealthyCheckMethod]; ok {

pkg/qingcloud/qingcloud.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ type Config struct {
4141
IsApp bool `yaml:"isApp,omitempty"`
4242
TagIDs []string `yaml:"tagIDs,omitempty"`
4343
InstanceIDs []string `yaml:"instanceIDs,omitempty"`
44+
PlaceGroupID string `yaml:"placeGroupID,omitempty"`
4445
}
4546

4647
// A single Kubernetes cluster can run in multiple zones,
@@ -211,8 +212,8 @@ func (qc *QingCloud) ensureLoadBalancer(ctx context.Context, _ string, service *
211212
klog.V(4).Infof("EnsureLoadBalancer lb %s config %s", spew.Sdump(lb), spew.Sdump(conf))
212213
if err != nil {
213214
if errors.IsResourceNotFound(err) && conf.Policy != ReuseExistingLB && conf.Policy != Shared {
214-
// will auto create lb with assigned eip
215-
klog.Infof("lb not found for service %s/%s, going to create lb with assigned eip ", service.Namespace, service.Name)
215+
// will auto create lb with assigned eip or vxnet
216+
klog.Infof("lb not found for service %s/%s, going to create lb with assigned eip or vxnet ", service.Namespace, service.Name)
216217
} else {
217218
return nil, fmt.Errorf("getLoadBalancer error: %v", err)
218219
}
@@ -339,6 +340,7 @@ func (qc *QingCloud) ensureLoadBalancer(ctx context.Context, _ string, service *
339340
VxNetID: conf.VxNetID,
340341
PrivateIPs: []*string{conf.InternalIP},
341342
EIPs: conf.EipIDs,
343+
PlaceGroupID: conf.PlaceGroupID,
342344
},
343345
})
344346
if err != nil {

0 commit comments

Comments
 (0)