@@ -25,10 +25,10 @@ import (
25
25
"strconv"
26
26
"strings"
27
27
28
- "github.com/xanzy/go- cloudstack/v2/cloudstack"
29
- "k8s.io/klog"
28
+ "github.com/apache/ cloudstack-go /v2/cloudstack"
29
+ "k8s.io/klog/v2 "
30
30
31
- v1 "k8s.io/api/core/v1"
31
+ corev1 "k8s.io/api/core/v1"
32
32
cloudprovider "k8s.io/cloud-provider"
33
33
)
34
34
@@ -50,7 +50,7 @@ type loadBalancer struct {
50
50
}
51
51
52
52
// GetLoadBalancer returns whether the specified load balancer exists, and if so, what its status is.
53
- func (cs * CSCloud ) GetLoadBalancer (ctx context.Context , clusterName string , service * v1 .Service ) (* v1 .LoadBalancerStatus , bool , error ) {
53
+ func (cs * CSCloud ) GetLoadBalancer (ctx context.Context , clusterName string , service * corev1 .Service ) (* corev1 .LoadBalancerStatus , bool , error ) {
54
54
klog .V (4 ).Infof ("GetLoadBalancer(%v, %v, %v)" , clusterName , service .Namespace , service .Name )
55
55
56
56
// Get the load balancer details and existing rules.
@@ -66,14 +66,14 @@ func (cs *CSCloud) GetLoadBalancer(ctx context.Context, clusterName string, serv
66
66
67
67
klog .V (4 ).Infof ("Found a load balancer associated with IP %v" , lb .ipAddr )
68
68
69
- status := & v1 .LoadBalancerStatus {}
70
- status .Ingress = append (status .Ingress , v1 .LoadBalancerIngress {IP : lb .ipAddr })
69
+ status := & corev1 .LoadBalancerStatus {}
70
+ status .Ingress = append (status .Ingress , corev1 .LoadBalancerIngress {IP : lb .ipAddr })
71
71
72
72
return status , true , nil
73
73
}
74
74
75
75
// EnsureLoadBalancer creates a new load balancer, or updates the existing one. Returns the status of the balancer.
76
- func (cs * CSCloud ) EnsureLoadBalancer (ctx context.Context , clusterName string , service * v1 .Service , nodes []* v1 .Node ) (status * v1 .LoadBalancerStatus , err error ) {
76
+ func (cs * CSCloud ) EnsureLoadBalancer (ctx context.Context , clusterName string , service * corev1 .Service , nodes []* corev1 .Node ) (status * corev1 .LoadBalancerStatus , err error ) {
77
77
klog .V (4 ).Infof ("EnsureLoadBalancer(%v, %v, %v, %v, %v, %v)" , clusterName , service .Namespace , service .Name , service .Spec .LoadBalancerIP , service .Spec .Ports , nodes )
78
78
79
79
if len (service .Spec .Ports ) == 0 {
@@ -88,9 +88,9 @@ func (cs *CSCloud) EnsureLoadBalancer(ctx context.Context, clusterName string, s
88
88
89
89
// Set the load balancer algorithm.
90
90
switch service .Spec .SessionAffinity {
91
- case v1 .ServiceAffinityNone :
91
+ case corev1 .ServiceAffinityNone :
92
92
lb .algorithm = "roundrobin"
93
- case v1 .ServiceAffinityClientIP :
93
+ case corev1 .ServiceAffinityClientIP :
94
94
lb .algorithm = "source"
95
95
default :
96
96
return nil , fmt .Errorf ("unsupported load balancer affinity: %v" , service .Spec .SessionAffinity )
@@ -193,14 +193,14 @@ func (cs *CSCloud) EnsureLoadBalancer(ctx context.Context, clusterName string, s
193
193
}
194
194
}
195
195
196
- status = & v1 .LoadBalancerStatus {}
197
- status .Ingress = []v1 .LoadBalancerIngress {{IP : lb .ipAddr }}
196
+ status = & corev1 .LoadBalancerStatus {}
197
+ status .Ingress = []corev1 .LoadBalancerIngress {{IP : lb .ipAddr }}
198
198
199
199
return status , nil
200
200
}
201
201
202
202
// UpdateLoadBalancer updates hosts under the specified load balancer.
203
- func (cs * CSCloud ) UpdateLoadBalancer (ctx context.Context , clusterName string , service * v1 .Service , nodes []* v1 .Node ) error {
203
+ func (cs * CSCloud ) UpdateLoadBalancer (ctx context.Context , clusterName string , service * corev1 .Service , nodes []* corev1 .Node ) error {
204
204
klog .V (4 ).Infof ("UpdateLoadBalancer(%v, %v, %v, %v)" , clusterName , service .Namespace , service .Name , nodes )
205
205
206
206
// Get the load balancer details and existing rules.
@@ -246,7 +246,7 @@ func (cs *CSCloud) UpdateLoadBalancer(ctx context.Context, clusterName string, s
246
246
247
247
// EnsureLoadBalancerDeleted deletes the specified load balancer if it exists, returning
248
248
// nil if the load balancer specified either didn't exist or was successfully deleted.
249
- func (cs * CSCloud ) EnsureLoadBalancerDeleted (ctx context.Context , clusterName string , service * v1 .Service ) error {
249
+ func (cs * CSCloud ) EnsureLoadBalancerDeleted (ctx context.Context , clusterName string , service * corev1 .Service ) error {
250
250
klog .V (4 ).Infof ("EnsureLoadBalancerDeleted(%v, %v, %v)" , clusterName , service .Namespace , service .Name )
251
251
252
252
// Get the load balancer details and existing rules.
@@ -286,12 +286,12 @@ func (cs *CSCloud) EnsureLoadBalancerDeleted(ctx context.Context, clusterName st
286
286
}
287
287
288
288
// GetLoadBalancerName retrieves the name of the LoadBalancer.
289
- func (cs * CSCloud ) GetLoadBalancerName (ctx context.Context , clusterName string , service * v1 .Service ) string {
289
+ func (cs * CSCloud ) GetLoadBalancerName (ctx context.Context , clusterName string , service * corev1 .Service ) string {
290
290
return cloudprovider .DefaultLoadBalancerName (service )
291
291
}
292
292
293
293
// getLoadBalancer retrieves the IP address and ID and all the existing rules it can find.
294
- func (cs * CSCloud ) getLoadBalancer (service * v1 .Service ) (* loadBalancer , error ) {
294
+ func (cs * CSCloud ) getLoadBalancer (service * corev1 .Service ) (* loadBalancer , error ) {
295
295
lb := & loadBalancer {
296
296
CloudStackClient : cs .client ,
297
297
name : cs .GetLoadBalancerName (context .TODO (), "" , service ),
@@ -329,7 +329,7 @@ func (cs *CSCloud) getLoadBalancer(service *v1.Service) (*loadBalancer, error) {
329
329
}
330
330
331
331
// verifyHosts verifies if all hosts belong to the same network, and returns the host ID's and network ID.
332
- func (cs * CSCloud ) verifyHosts (nodes []* v1 .Node ) ([]string , string , error ) {
332
+ func (cs * CSCloud ) verifyHosts (nodes []* corev1 .Node ) ([]string , string , error ) {
333
333
hostNames := map [string ]bool {}
334
334
for _ , node := range nodes {
335
335
hostNames [strings .ToLower (node .Name )] = true
@@ -456,7 +456,7 @@ func (lb *loadBalancer) releaseLoadBalancerIP() error {
456
456
457
457
// checkLoadBalancerRule checks if the rule already exists and if it does, if it can be updated. If
458
458
// it does exist but cannot be updated, it will delete the existing rule so it can be created again.
459
- func (lb * loadBalancer ) checkLoadBalancerRule (lbRuleName string , port v1 .ServicePort , protocol LoadBalancerProtocol ) (* cloudstack.LoadBalancerRule , bool , error ) {
459
+ func (lb * loadBalancer ) checkLoadBalancerRule (lbRuleName string , port corev1 .ServicePort , protocol LoadBalancerProtocol ) (* cloudstack.LoadBalancerRule , bool , error ) {
460
460
lbRule , ok := lb .rules [lbRuleName ]
461
461
if ! ok {
462
462
return nil , false , nil
@@ -490,7 +490,7 @@ func (lb *loadBalancer) updateLoadBalancerRule(lbRuleName string, protocol LoadB
490
490
}
491
491
492
492
// createLoadBalancerRule creates a new load balancer rule and returns it's ID.
493
- func (lb * loadBalancer ) createLoadBalancerRule (lbRuleName string , port v1 .ServicePort , protocol LoadBalancerProtocol ) (* cloudstack.LoadBalancerRule , error ) {
493
+ func (lb * loadBalancer ) createLoadBalancerRule (lbRuleName string , port corev1 .ServicePort , protocol LoadBalancerProtocol ) (* cloudstack.LoadBalancerRule , error ) {
494
494
p := lb .LoadBalancer .NewCreateLoadBalancerRuleParams (
495
495
lb .algorithm ,
496
496
lbRuleName ,
0 commit comments