Skip to content

Commit 58457f3

Browse files
committed
Normalize NodeBalancer type annotation to lowercase for safety
Add automatic lowercase conversion for NodeBalancer type annotations to prevent typos and inconsistent casing. Update documentation to reflect that NodeBalancer types should always be specified in lowercase (e.g., `premium_40gb` instead of `premium_40GB`).
1 parent 783c6ae commit 58457f3

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

cloud/linode/loadbalancers.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,8 @@ func (l *loadbalancers) GetLoadBalancerTags(_ context.Context, clusterName strin
762762
func (l *loadbalancers) GetLinodeNBType(service *v1.Service) linodego.NodeBalancerPlanType {
763763
typeStr, ok := service.GetAnnotations()[annotations.AnnLinodeNodeBalancerType]
764764
if ok {
765+
// For Safety - avoid typos and inconsistent casing
766+
typeStr = strings.ToLower(typeStr)
765767
switch linodego.NodeBalancerPlanType(typeStr) {
766768
case linodego.NBTypeCommon: // need to add this because of the golint check
767769
return linodego.NBTypeCommon

docs/configuration/annotations.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ The keys and the values in [annotations must be strings](https://kubernetes.io/d
3838
| `tags` | string | | A comma separated list of tags to be applied to the NodeBalancer instance |
3939
| `firewall-id` | int | | An existing Cloud Firewall ID to be attached to the NodeBalancer instance. See [Firewall Setup](firewall.md) |
4040
| `firewall-acl` | string | | The Firewall rules to be applied to the NodeBalancer. See [Firewall Configuration](#firewall-configuration) |
41-
| `nodebalancer-type` | string | | The type of NodeBalancer to create (options: common, premium, premium_40GB). See [NodeBalancer Types](#nodebalancer-type) |
41+
| `nodebalancer-type` | string | | The type of NodeBalancer to create (options: common, premium, premium_40gb). See [NodeBalancer Types](#nodebalancer-type). Note: NodeBalancer types should always be specified in lowercase. |
4242
| `enable-ipv6-ingress` | bool | `false` | When `true`, both IPv4 and IPv6 addresses will be included in the LoadBalancerStatus ingress |
4343
| `backend-ipv4-range` | string | | The IPv4 range from VPC subnet to be applied to the NodeBalancer backend. See [Nodebalancer VPC Configuration](#nodebalancer-vpc-configuration) |
4444
| `backend-vpc-name` | string | | VPC which is connected to the NodeBalancer backend. See [Nodebalancer VPC Configuration](#nodebalancer-vpc-configuration) |
@@ -123,7 +123,9 @@ metadata:
123123
```
124124

125125
### NodeBalancer Type
126-
Linode supports nodebalancers of different types: common, premium, and premium_40GB. By default, nodebalancers of type common are provisioned. If an account is allowed to provision premium nodebalancers and one wants to use them, it can be achieved by specifying the annotation:
126+
Linode supports nodebalancers of different types: common, premium, and premium_40gb. By default, nodebalancers of type common are provisioned. If an account is allowed to provision premium nodebalancers and one wants to use them, it can be achieved by specifying the annotation:
127+
128+
**Note:** NodeBalancer types should always be specified in lowercase. The controller will automatically convert uppercase values to lowercase for safety.
127129
```yaml
128130
metadata:
129131
annotations:

docs/configuration/environment.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ The CCM supports the following flags:
4646
| `--load-balancer-type` | String | `nodebalancer` | Configures which type of load-balancing to use (options: nodebalancer, cilium-bgp) |
4747
| `--bgp-node-selector` | String | `""` | Node selector to use to perform shared IP fail-over with BGP |
4848
| `--ip-holder-suffix` | String | `""` | Suffix to append to the IP holder name when using shared IP fail-over with BGP |
49-
| `--default-nodebalancer-type` | String | `common` | Default type of NodeBalancer to create (options: common, premium, premium_40GB) |
49+
| `--default-nodebalancer-type` | String | `common` | Default type of NodeBalancer to create (options: common, premium, premium_40gb). Note: NodeBalancer types should always be specified in lowercase. |
5050
| `--nodebalancer-tags` | String (comma separated) | | Linode tags to apply to all NodeBalancers |
5151
| `--nodebalancer-backend-ipv4-subnet` | String | `""` | ipv4 subnet to use for NodeBalancer backends |
5252
| `--nodebalancer-backend-ipv4-subnet-id` | Int | `""` | ipv4 subnet id to use for NodeBalancer backends |

0 commit comments

Comments
 (0)