Skip to content

Commit be69ff5

Browse files
author
Rahul Sharma
committed
address review comments
1 parent 814247e commit be69ff5

File tree

6 files changed

+22
-8
lines changed

6 files changed

+22
-8
lines changed

cloud/linode/cloud.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,13 @@ func newCloud() (cloudprovider.Interface, error) {
160160
if Options.DisableNodeBalancerVPCBackends {
161161
klog.Infof("NodeBalancer VPC backends are disabled, no VPC backends will be created for NodeBalancers")
162162
Options.NodeBalancerBackendIPv4SubnetID = 0
163+
Options.NodeBalancerBackendIPv4SubnetName = ""
163164
} else if Options.NodeBalancerBackendIPv4SubnetName != "" {
164165
Options.NodeBalancerBackendIPv4SubnetID, err = getNodeBalancerBackendIPv4SubnetID(linodeClient)
165166
if err != nil {
166167
return nil, fmt.Errorf("failed to get backend IPv4 subnet ID for subnet name %s: %w", Options.NodeBalancerBackendIPv4SubnetName, err)
167168
}
168-
klog.Infof("Using NodeBalancer backend IPv4 subnet ID %d for subnet name %s\n", Options.NodeBalancerBackendIPv4SubnetID, Options.NodeBalancerBackendIPv4SubnetName)
169+
klog.Infof("Using NodeBalancer backend IPv4 subnet ID %d for subnet name %s", Options.NodeBalancerBackendIPv4SubnetID, Options.NodeBalancerBackendIPv4SubnetName)
169170
}
170171

171172
instanceCache = newInstances(linodeClient)

cloud/linode/loadbalancers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1177,7 +1177,7 @@ func getPortConfigAnnotation(service *v1.Service, port int) (portConfigAnnotatio
11771177
// getNodePrivateIP provides the Linode Backend IP the NodeBalancer will communicate with.
11781178
// If CCM runs within VPC and DisableNodeBalancerVPCBackends is set to false, it will
11791179
// use NodeInternalIP of node.
1180-
// For services outside of VPC, it will use linode specific pirvate IP address
1180+
// For services outside of VPC, it will use linode specific private IP address
11811181
// Backend IP can be overwritten to the one specified using AnnLinodeNodePrivateIP
11821182
// annotation over the NodeInternalIP.
11831183
func getNodePrivateIP(node *v1.Node, subnetID int) string {

cloud/linode/vpc_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,13 +225,19 @@ func TestGetSubnetID(t *testing.T) {
225225
})
226226
}
227227

228-
func Test_getNodeBalancerBackendIPv4SubnetID(t *testing.T) {
228+
func TestGetNodeBalancerBackendIPv4SubnetID(t *testing.T) {
229229
t.Run("VPC not found", func(t *testing.T) {
230230
ctrl := gomock.NewController(t)
231231
defer ctrl.Finish()
232232
client := mocks.NewMockClient(ctrl)
233233
currVPCNames := Options.VPCNames
234-
defer func() { Options.VPCNames = currVPCNames }()
234+
currVPCIDs := vpcIDs
235+
currSubnetIDs := subnetIDs
236+
defer func() {
237+
Options.VPCNames = currVPCNames
238+
vpcIDs = currVPCIDs
239+
subnetIDs = currSubnetIDs
240+
}()
235241
Options.VPCNames = "vpc-test1,vpc-test2,vpc-test3"
236242
vpcIDs = map[string]int{"vpc-test2": 2, "vpc-test3": 3}
237243
subnetIDs = map[string]int{"test1": 1, "test2": 2, "test3": 3}

deploy/chart/templates/daemonset.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,19 @@ spec:
9090
{{- if and .Values.routeController .Values.routeController.subnetNames }}
9191
{{- $subnetNames = .Values.routeController.subnetNames }}
9292
{{- end }}
93+
{{- if .Values.disableNodeBalancerVPCBackends }}
94+
- --disable-nodebalancer-vpc-backends={{ .Values.disableNodeBalancerVPCBackends }}
95+
{{- end }}
9396
{{- $nbvpcBackendIpv4SubnetName := .Values.nodeBalancerBackendIpv4SubnetName }}
9497
{{- $nbvpcBackendIpv4SubnetID := .Values.nodeBalancerBackendIpv4SubnetID }}
9598
{{- if and $nbvpcBackendIpv4SubnetName $nbvpcBackendIpv4SubnetID }}
9699
{{- fail "Both nodeBalancerBackendIpv4SubnetName and nodeBalancerBackendIpv4SubnetID are set. Please use only one." }}
97100
{{- end }}
98101
{{- if $nbvpcBackendIpv4SubnetName }}
99-
- --node-balancer-backend-ipv4-subnet-name={{ $nbvpcBackendIpv4SubnetName }}
102+
- --nodebalancer-backend-ipv4-subnet-name={{ $nbvpcBackendIpv4SubnetName }}
100103
{{- end }}
101104
{{- if $nbvpcBackendIpv4SubnetID }}
102-
- --node-balancer-backend-ipv4-subnet-id={{ $nbvpcBackendIpv4SubnetID }}
105+
- --nodebalancer-backend-ipv4-subnet-id={{ $nbvpcBackendIpv4SubnetID }}
103106
{{- end }}
104107
{{- if .Values.routeController }}
105108
- --enable-route-controller=true

deploy/chart/values.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ tolerations:
9797
# This can also be controlled per-service using the "service.beta.kubernetes.io/linode-loadbalancer-enable-ipv6-ingress" annotation
9898
# enableIPv6ForLoadBalancers: true
9999

100+
# disableNodeBalancerVPCBackends is used to disable the use of VPC backends for NodeBalancers.
101+
# When set to true, NodeBalancers will use linode private IPs for backends instead of VPC IPs.
102+
# disableNodeBalancerVPCBackends: false
103+
100104
# nodeBalancerBackendIPv4Subnet is the subnet to use for the backend ips of the NodeBalancer
101105
# nodeBalancerBackendIPv4Subnet: ""
102106

docs/configuration/environment.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ The CCM supports the following flags:
4949
| `--nodebalancer-backend-ipv4-subnet` | `""` | ipv4 subnet to use for NodeBalancer backends |
5050
| `--nodebalancer-backend-ipv4-subnet-id` | `""` | ipv4 subnet id to use for NodeBalancer backends |
5151
| `--nodebalancer-backend-ipv4-subnet-name` | `""` | ipv4 subnet name to use for NodeBalancer backends |
52-
| `--disable-nodebalancer-vpc-backends` | `false` | use VPC specific ip-addresses for nodebalancer backend ips when running in VPC (set to `true` only for backward compatibility if needed) |
52+
| `--disable-nodebalancer-vpc-backends` | `false` | don't use VPC specific ip-addresses for nodebalancer backend ips when running in VPC (set to `true` for backward compatibility if needed) |
5353
| `--enable-ipv6-for-loadbalancers` | `false` | Set both IPv4 and IPv6 addresses for all LoadBalancer services (when disabled, only IPv4 is used). This can also be configured per-service using the `service.beta.kubernetes.io/linode-loadbalancer-enable-ipv6-ingress` annotation. |
5454
| `--node-cidr-mask-size-ipv4` | `24` | ipv4 cidr mask size for pod cidrs allocated to nodes |
5555
| `--node-cidr-mask-size-ipv6` | `64` | ipv6 cidr mask size for pod cidrs allocated to nodes |
@@ -107,7 +107,7 @@ To use dedicated subnet within VPC for nodebalancer backend ips, one can use one
107107

108108
If no specific subnet is specified, by default, CCM will use the `default` subnet or the first subnet configured in `--subnet-names` flag for nodebalancer backend ips
109109

110-
`--disable-nodebalancer-vpc-backends` disables using VPC specific ips as nodebalancer backends and relies on machines to have linode specific [private addresses](https://techdocs.akamai.com/cloud-computing/docs/managing-ip-addresses-on-a-compute-instance#ipv4). In future, this flag might get removed as this is added for backward compatibility for now. We encourage users not to use this flag if possible.
110+
`--disable-nodebalancer-vpc-backends` when set to `true` disables using VPC specific ips as nodebalancer backends and relies on machines to have linode specific [private addresses](https://techdocs.akamai.com/cloud-computing/docs/managing-ip-addresses-on-a-compute-instance#ipv4). In future, this flag might get removed as this is added for backward compatibility for now. We encourage users not to use this flag if possible.
111111

112112
`--nodebalancer-backend-ipv4-subnet` can be used to make sure if nodebalancer backend ips are manually specified in service annotation, they lie within the specified subnet range.
113113

0 commit comments

Comments
 (0)