Skip to content

Commit 26c09be

Browse files
authored
feat: Define ServiceLoadBalancer Configuration API (#778)
**What problem does this PR solve?**: This adds an optional configuration for the ServiceLoadBalancer Addon, consisting of one or more IPv4 address ranges, e.g., ```yaml apiVersion: cluster.x-k8s.io/v1beta1 kind: Cluster metadata: name: <NAME> spec: topology: variables: - name: clusterConfig value: addons: serviceLoadBalancer: provider: MetalLB configuration: addressRanges: - start: 10.100.1.1 end: 10.100.1.20 - start: 10.100.1.51 end: 10.100.1.70 ``` (This is a copy of #763. I had to close that after #755 added required checks that can't be run from PRs from public forks. ) **Which issue(s) this PR fixes**: Fixes # **How Has This Been Tested?**: <!-- Please describe the tests that you ran to verify your changes. Provide output from the tests and any manual steps needed to replicate the tests. --> **Special notes for your reviewer**: <!-- Use this to provide any additional information to the reviewers. This may include: - Best way to review the PR. - Where the author wants the most review attention on. - etc. -->
1 parent df4fa40 commit 26c09be

6 files changed

+166
-3
lines changed

api/v1alpha1/addon_types.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,4 +257,25 @@ type ServiceLoadBalancer struct {
257257
// +kubebuilder:validation:Enum=MetalLB
258258
// +kubebuilder:validation:Required
259259
Provider string `json:"provider"`
260+
261+
// Configuration for the chosen ServiceLoadBalancer provider.
262+
// +kubebuilder:validation:Optional
263+
Configuration *ServiceLoadBalancerConfiguration `json:"configuration,omitempty"`
264+
}
265+
266+
type ServiceLoadBalancerConfiguration struct {
267+
// AddressRanges is a list of IPv4 address ranges the
268+
// provider uses to choose an address for a load balancer.
269+
// +kubebuilder:validation:Required
270+
// +kubebuilder:validation:MinItems=1
271+
AddressRanges []AddressRange `json:"addressRanges"`
272+
}
273+
274+
// AddressRange defines an IPv4 range.
275+
type AddressRange struct {
276+
// +kubebuilder:validation:Format=ipv4
277+
Start string `json:"start"`
278+
279+
// +kubebuilder:validation:Format=ipv4
280+
End string `json:"end"`
260281
}

api/v1alpha1/crds/caren.nutanix.com_awsclusterconfigs.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,31 @@ spec:
218218
type: object
219219
serviceLoadBalancer:
220220
properties:
221+
configuration:
222+
description: Configuration for the chosen ServiceLoadBalancer provider.
223+
properties:
224+
addressRanges:
225+
description: |-
226+
AddressRanges is a list of IPv4 address ranges the
227+
provider uses to choose an address for a load balancer.
228+
items:
229+
description: AddressRange defines an IPv4 range.
230+
properties:
231+
end:
232+
format: ipv4
233+
type: string
234+
start:
235+
format: ipv4
236+
type: string
237+
required:
238+
- end
239+
- start
240+
type: object
241+
minItems: 1
242+
type: array
243+
required:
244+
- addressRanges
245+
type: object
221246
provider:
222247
description: |-
223248
The LoadBalancer-type Service provider to deploy. Not required in infrastructures where

api/v1alpha1/crds/caren.nutanix.com_dockerclusterconfigs.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,31 @@ spec:
218218
type: object
219219
serviceLoadBalancer:
220220
properties:
221+
configuration:
222+
description: Configuration for the chosen ServiceLoadBalancer provider.
223+
properties:
224+
addressRanges:
225+
description: |-
226+
AddressRanges is a list of IPv4 address ranges the
227+
provider uses to choose an address for a load balancer.
228+
items:
229+
description: AddressRange defines an IPv4 range.
230+
properties:
231+
end:
232+
format: ipv4
233+
type: string
234+
start:
235+
format: ipv4
236+
type: string
237+
required:
238+
- end
239+
- start
240+
type: object
241+
minItems: 1
242+
type: array
243+
required:
244+
- addressRanges
245+
type: object
221246
provider:
222247
description: |-
223248
The LoadBalancer-type Service provider to deploy. Not required in infrastructures where

api/v1alpha1/crds/caren.nutanix.com_nutanixclusterconfigs.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,31 @@ spec:
218218
type: object
219219
serviceLoadBalancer:
220220
properties:
221+
configuration:
222+
description: Configuration for the chosen ServiceLoadBalancer provider.
223+
properties:
224+
addressRanges:
225+
description: |-
226+
AddressRanges is a list of IPv4 address ranges the
227+
provider uses to choose an address for a load balancer.
228+
items:
229+
description: AddressRange defines an IPv4 range.
230+
properties:
231+
end:
232+
format: ipv4
233+
type: string
234+
start:
235+
format: ipv4
236+
type: string
237+
required:
238+
- end
239+
- start
240+
type: object
241+
minItems: 1
242+
type: array
243+
required:
244+
- addressRanges
245+
type: object
221246
provider:
222247
description: |-
223248
The LoadBalancer-type Service provider to deploy. Not required in infrastructures where

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 41 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/content/addons/serviceloadbalancer.md

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@ The Service Load Balancer is the component that backs this Kubernetes Service, e
1010
a Virtual IP, creating a machine that runs load balancer software, by delegating to APIs, such as
1111
the underlying infrastructure, or a hardware load balancer.
1212

13+
The Service Load Balancer can choose the Virtual IP from a pre-defined address range. You can use
14+
CAREN to configure one or more IPv4 ranges. For additional options, configure the Service Load
15+
Balancer yourself after it is deployed.
16+
1317
CAREN currently supports the following Service Load Balancers:
1418

1519
- [MetalLB]
1620

17-
## Example
21+
## Examples
1822

1923
To enable deployment of MetalLB on a cluster, specify the following values:
2024

@@ -33,7 +37,30 @@ spec:
3337
provider: MetalLB
3438
```
3539
36-
See [MetalLB documentation] for details on configuration.
40+
To enable MetalLB, and configure two address IPv4 ranges, specify the following values:
41+
42+
```yaml
43+
apiVersion: cluster.x-k8s.io/v1beta1
44+
kind: Cluster
45+
metadata:
46+
name: <NAME>
47+
spec:
48+
topology:
49+
variables:
50+
- name: clusterConfig
51+
value:
52+
addons:
53+
serviceLoadBalancer:
54+
provider: MetalLB
55+
configuration:
56+
addressRanges:
57+
- start: 10.100.1.1
58+
end: 10.100.1.20
59+
- start: 10.100.1.51
60+
end: 10.100.1.70
61+
```
62+
63+
See [MetalLB documentation] for more configuration details.
3764
3865
[external load balancer]: https://kubernetes.io/docs/tasks/access-application-cluster/create-external-load-balancer/
3966
[MetalLB]: https://metallb.org

0 commit comments

Comments
 (0)