Skip to content

Commit

Permalink
Merge pull request #206 from vultr/node-c
Browse files Browse the repository at this point in the history
add vlb node count
  • Loading branch information
happytreees committed Sep 12, 2023
2 parents e70781a + a844de4 commit 3319cdd
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 22 deletions.
45 changes: 23 additions & 22 deletions docs/load-balancers.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,26 @@ The Vultr CCM allows you to configure your `LoadBalancer` resource to be deploye

The annotations are listed below. Please note that all annotations listed below **must** be prepended with `service.beta.kubernetes.io/vultr-loadbalancer-` and are case sensitive.

| Annotation (Suffix) | Values | Default | Description |
|------------------------------------|-----------------------------------|---------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `protocol` | `tcp`, `http` | `tcp` | This is used to specify the protocol to be used for your LoadBalancer protocol. |
| `backend-protocol` | `http`, `https`, or `tcp` | `http`, `https`, or `tcp` depending on `protocol` | This is used to set the backend protocol from load balancer to application(s). Note: Only certain protocols can be set here; anything out of scope will be defaulted to `protocol` |
| `https-ports` | string | | Defines which ports should be used for HTTPS. You can pass in a comma separated list: 443,8443 |
| `ssl` | string | | The string you provide should be the name of a Kubernetes TLS Secret which store your cert + key |
| `ssl-pass-through` | `true`, `false` | `false` | If you want SSL termination to happen on your `pods` or `ingress` then this must be enabled. This is to be used with the `https-ports` annotation |
| `proxy-protocol` | `true`, `false` | `false` | Indicates whether Proxy protocol should be enabled. |
| `healthcheck-protocol` | `tcp` `http` | `tcp` | The protocol to be used for your LoadBalancer HealthCheck |
| `healthcheck-path` | string | `/` | The URL path to check on the back-end during health checks |
| `healthcheck-port` | int | `defaults to what kubernetes defines` | The port that should be called for health checks |
| `healthcheck-check-interval` | int | `15` | Interval between health checks (in seconds) |
| `healthcheck-response-timeout` | int | `5` | Response timeout (in seconds) |
| `healthcheck-unhealthy-threshold` | int | `5` | Number of unhealthy requests before a back-end is removed |
| `healthcheck-healthy-threshold` | int | `5` | Number of healthy requests before a back-end is added back in |
| `algorithm` | `least_connections`, `roundrobin` | `roundrobin` | Balancing algorithm |
| `ssl-redirect` | `true`, `false` | `false` | Force HTTP to HTTPS |
| `sticky-session-enabled` | `on`, `off` | `off` | Enables Sticky Sessions. If enabled you must provide `sticky-session-cookie-name` |
| `sticky-session-cookie-name"` | string | | Name of sticky session |
| `firewall-rules` | string | | This is used to let you define your firewall rules. They must be supplied with "ip-with-with-subnet,port" format with `;` breaking up firewall rules. Example: `0.0.0.0/0,80;0.0.0.0/0,90` |
| ~~`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. |
| Annotation (Suffix) | Values | Default | Description |
|------------------------------------|-----------------------------------|---------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `protocol` | `tcp`, `http` | `tcp` | This is used to specify the protocol to be used for your LoadBalancer protocol. |
| `backend-protocol` | `http`, `https`, or `tcp` | `http`, `https`, or `tcp` depending on `protocol` | This is used to set the backend protocol from load balancer to application(s). Note: Only certain protocols can be set here; anything out of scope will be defaulted to `protocol` |
| `https-ports` | string | | Defines which ports should be used for HTTPS. You can pass in a comma separated list: 443,8443 |
| `ssl` | string | | The string you provide should be the name of a Kubernetes TLS Secret which store your cert + key |
| `ssl-pass-through` | `true`, `false` | `false` | If you want SSL termination to happen on your `pods` or `ingress` then this must be enabled. This is to be used with the `https-ports` annotation |
| `proxy-protocol` | `true`, `false` | `false` | Indicates whether Proxy protocol should be enabled. |
| `healthcheck-protocol` | `tcp` `http` | `tcp` | The protocol to be used for your LoadBalancer HealthCheck |
| `healthcheck-path` | string | `/` | The URL path to check on the back-end during health checks |
| `healthcheck-port` | int | `defaults to what kubernetes defines` | The port that should be called for health checks |
| `healthcheck-check-interval` | int | `15` | Interval between health checks (in seconds) |
| `healthcheck-response-timeout` | int | `5` | Response timeout (in seconds) |
| `healthcheck-unhealthy-threshold` | int | `5` | Number of unhealthy requests before a back-end is removed |
| `healthcheck-healthy-threshold` | int | `5` | Number of healthy requests before a back-end is added back in |
| `algorithm` | `least_connections`, `roundrobin` | `roundrobin` | Balancing algorithm |
| `ssl-redirect` | `true`, `false` | `false` | Force HTTP to HTTPS |
| `sticky-session-enabled` | `on`, `off` | `off` | Enables Sticky Sessions. If enabled you must provide `sticky-session-cookie-name` |
| `sticky-session-cookie-name"` | string | | Name of sticky session |
| `firewall-rules` | string | | This is used to let you define your firewall rules. They must be supplied with "ip-with-with-subnet,port" format with `;` breaking up firewall rules. Example: `0.0.0.0/0,80;0.0.0.0/0,90` |
| ~~`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. |
1 change: 1 addition & 0 deletions vultr/loadbalancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ func TestLoadbalancers_EnsureLoadBalancer(t *testing.T) {
UID: "lb-name",
Annotations: map[string]string{
annoVultrFirewallRules: "cloudflare,80;10.0.0.0/8,80",
annoVultrNodeCount: "5",
},
},
Spec: v1.ServiceSpec{
Expand Down
16 changes: 16 additions & 0 deletions vultr/loadbalancers.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ const (
annoVultrPrivateNetwork = "service.beta.kubernetes.io/vultr-loadbalancer-private-network"
annoVultrVPC = "service.beta.kubernetes.io/vultr-loadbalancer-vpc"

annoVultrNodeCount = "service.beta.kubernetes.io/vultr-loadbalancer-node-count"

// Supported Protocols
protocolHTTP = "http"
protocolHTTPS = "https"
Expand Down Expand Up @@ -312,6 +314,19 @@ func (l *loadbalancers) buildLoadBalancerRequest(service *v1.Service, nodes []*v
return nil, err
}

nodeC := 1

if count, ok := service.Annotations[annoVultrNodeCount]; ok {
nodeC, err = strconv.Atoi(count)
if err != nil {
return nil, err
}

if nodeC&1 == 0 {
return nil, fmt.Errorf("%s must be odd", annoVultrNodeCount)
}
}

return &govultr.LoadBalancerReq{
Label: getDefaultLBName(service), // will always be set
Instances: instances, // will always be set
Expand All @@ -324,6 +339,7 @@ func (l *loadbalancers) buildLoadBalancerRequest(service *v1.Service, nodes []*v
BalancingAlgorithm: getAlgorithm(service), // will always be set
FirewallRules: firewallRules, // need to check
VPC: govultr.StringToStringPtr(vpc), // need to check
Nodes: nodeC, // need to check
}, nil
}

Expand Down

0 comments on commit 3319cdd

Please sign in to comment.