Skip to content

Commit

Permalink
feat: Define ServiceLoadBalancer Configuration API (#778)
Browse files Browse the repository at this point in the history
**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.
-->
  • Loading branch information
dlipovetsky authored Jul 3, 2024
1 parent df4fa40 commit 26c09be
Show file tree
Hide file tree
Showing 6 changed files with 166 additions and 3 deletions.
21 changes: 21 additions & 0 deletions api/v1alpha1/addon_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,4 +257,25 @@ type ServiceLoadBalancer struct {
// +kubebuilder:validation:Enum=MetalLB
// +kubebuilder:validation:Required
Provider string `json:"provider"`

// Configuration for the chosen ServiceLoadBalancer provider.
// +kubebuilder:validation:Optional
Configuration *ServiceLoadBalancerConfiguration `json:"configuration,omitempty"`
}

type ServiceLoadBalancerConfiguration struct {
// AddressRanges is a list of IPv4 address ranges the
// provider uses to choose an address for a load balancer.
// +kubebuilder:validation:Required
// +kubebuilder:validation:MinItems=1
AddressRanges []AddressRange `json:"addressRanges"`
}

// AddressRange defines an IPv4 range.
type AddressRange struct {
// +kubebuilder:validation:Format=ipv4
Start string `json:"start"`

// +kubebuilder:validation:Format=ipv4
End string `json:"end"`
}
25 changes: 25 additions & 0 deletions api/v1alpha1/crds/caren.nutanix.com_awsclusterconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,31 @@ spec:
type: object
serviceLoadBalancer:
properties:
configuration:
description: Configuration for the chosen ServiceLoadBalancer provider.
properties:
addressRanges:
description: |-
AddressRanges is a list of IPv4 address ranges the
provider uses to choose an address for a load balancer.
items:
description: AddressRange defines an IPv4 range.
properties:
end:
format: ipv4
type: string
start:
format: ipv4
type: string
required:
- end
- start
type: object
minItems: 1
type: array
required:
- addressRanges
type: object
provider:
description: |-
The LoadBalancer-type Service provider to deploy. Not required in infrastructures where
Expand Down
25 changes: 25 additions & 0 deletions api/v1alpha1/crds/caren.nutanix.com_dockerclusterconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,31 @@ spec:
type: object
serviceLoadBalancer:
properties:
configuration:
description: Configuration for the chosen ServiceLoadBalancer provider.
properties:
addressRanges:
description: |-
AddressRanges is a list of IPv4 address ranges the
provider uses to choose an address for a load balancer.
items:
description: AddressRange defines an IPv4 range.
properties:
end:
format: ipv4
type: string
start:
format: ipv4
type: string
required:
- end
- start
type: object
minItems: 1
type: array
required:
- addressRanges
type: object
provider:
description: |-
The LoadBalancer-type Service provider to deploy. Not required in infrastructures where
Expand Down
25 changes: 25 additions & 0 deletions api/v1alpha1/crds/caren.nutanix.com_nutanixclusterconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,31 @@ spec:
type: object
serviceLoadBalancer:
properties:
configuration:
description: Configuration for the chosen ServiceLoadBalancer provider.
properties:
addressRanges:
description: |-
AddressRanges is a list of IPv4 address ranges the
provider uses to choose an address for a load balancer.
items:
description: AddressRange defines an IPv4 range.
properties:
end:
format: ipv4
type: string
start:
format: ipv4
type: string
required:
- end
- start
type: object
minItems: 1
type: array
required:
- addressRanges
type: object
provider:
description: |-
The LoadBalancer-type Service provider to deploy. Not required in infrastructures where
Expand Down
42 changes: 41 additions & 1 deletion api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 29 additions & 2 deletions docs/content/addons/serviceloadbalancer.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@ The Service Load Balancer is the component that backs this Kubernetes Service, e
a Virtual IP, creating a machine that runs load balancer software, by delegating to APIs, such as
the underlying infrastructure, or a hardware load balancer.

The Service Load Balancer can choose the Virtual IP from a pre-defined address range. You can use
CAREN to configure one or more IPv4 ranges. For additional options, configure the Service Load
Balancer yourself after it is deployed.

CAREN currently supports the following Service Load Balancers:

- [MetalLB]

## Example
## Examples

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

Expand All @@ -33,7 +37,30 @@ spec:
provider: MetalLB
```
See [MetalLB documentation] for details on configuration.
To enable MetalLB, and configure two address IPv4 ranges, specify the following values:
```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
```
See [MetalLB documentation] for more configuration details.
[external load balancer]: https://kubernetes.io/docs/tasks/access-application-cluster/create-external-load-balancer/
[MetalLB]: https://metallb.org
Expand Down

0 comments on commit 26c09be

Please sign in to comment.