Skip to content

Commit

Permalink
add vlb create anno (#213)
Browse files Browse the repository at this point in the history
* add vlb create anno

* lint fix
  • Loading branch information
happytreees committed Sep 28, 2023
1 parent d767651 commit 71df755
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/load-balancers.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ The annotations are listed below. Please note that all annotations listed below
| ~~`private-network`~~ (deprecated) | ~~`true` or `false`~~ | ~~`false`~~ | **Deprecated Please use vpc**. ~~This is used to attach your load balancer to a private network. If `true` the CCM will pull the `private_network_id` that is attached to the node that the CCM is running on.~~ |
| `vpc` | `true` or `false` | `false` | This is used to attach your load balancer to a private network. If `true` the CCM will pull the `vpc_id` that is attached to the node that the CCM is running on. |
| `node-count` | int | 1 | Number of LoadBalancer nodes to have. Only odd numbers are supported. |
| `create` | `true` or `false` | `true` | This is used to determine whether or not to create a Vultr loadbalancer |
9 changes: 9 additions & 0 deletions vultr/loadbalancers.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ import (
const (
annoVultrLoadBalancerID = "kubernetes.vultr.com/load-balancer-id" //nolint (this is unused)

// annoVultrLoadBalancerCreate defaults to true and is to specify whether or not to create a VLB for the svc
annoVultrLoadBalancerCreate = "kubernetes.vultr.com/load-balancer-create"

// annoVultrLBProtocol is the annotation used to specify
// which protocol should be used for a Load Balancer.
// Note that if annoVultrLBHTTPSPorts is defined then this will be overridden to HTTPS
Expand Down Expand Up @@ -138,6 +141,12 @@ func (l *loadbalancers) EnsureLoadBalancer(ctx context.Context, clusterName stri
return nil, err
}

if create, ok := service.Annotations[annoVultrLoadBalancerCreate]; ok {
if strings.EqualFold(create, "false") {
return nil, fmt.Errorf("%s set to %s - load balancer will not be created", annoVultrLoadBalancerCreate, create)
}
}

// if exists is false and the err above was nil then this is errLbNotFound
if !exists {
klog.Infof("Load balancer for cluster %q doesn't exist, creating", clusterName)
Expand Down

0 comments on commit 71df755

Please sign in to comment.