Skip to content

Commit e42d887

Browse files
feat: Add the ServiceLoadbalancer Addon, with MetalLB as first provider (#592)
**What problem does this PR solve?**: Adds the `ServiceLoadbalancer` addon, and support for MetalLB as the first provider. ### TODO: - [x] API type - [x] Generic handler - [x] MetalLB handler - [x] Deploy MetalLB Helm chart - [x] Default configuration for MetalLB Helm chart - [ ] Document the ServiceLoadbalancer Addon. **Which issue(s) this PR fixes**: Fixes https://jira.nutanix.com/browse/D2IQ-100444 **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. --> --------- Co-authored-by: Jimmi Dyson <[email protected]>
1 parent 968a084 commit e42d887

File tree

19 files changed

+506
-3
lines changed

19 files changed

+506
-3
lines changed

api/v1alpha1/addon_types.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ const (
2424

2525
VirtualIPProviderKubeVIP = "KubeVIP"
2626

27+
ServiceLoadBalancerProviderMetalLB = "MetalLB"
28+
2729
AddonStrategyClusterResourceSet AddonStrategy = "ClusterResourceSet"
2830
AddonStrategyHelmAddon AddonStrategy = "HelmAddon"
2931

@@ -69,6 +71,9 @@ type Addons struct {
6971

7072
// +optional
7173
CSIProviders *CSI `json:"csi,omitempty"`
74+
75+
// +optional
76+
ServiceLoadBalancer *ServiceLoadBalancer `json:"serviceLoadBalancer,omitempty"`
7277
}
7378

7479
type AddonStrategy string
@@ -160,3 +165,10 @@ type CCM struct {
160165
// +optional
161166
Credentials *corev1.LocalObjectReference `json:"credentials,omitempty"`
162167
}
168+
169+
type ServiceLoadBalancer struct {
170+
// The LoadBalancer-type Service provider to deploy. Not required in infrastructures where
171+
// the CCM acts as the provider.
172+
// +kubebuilder:validation:Enum=MetalLB
173+
Provider string `json:"provider"`
174+
}

api/v1alpha1/constants.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@ const (
1414
AWSVariableName = "aws"
1515
// NutanixVariableName is the Nutanix config patch variable name.
1616
NutanixVariableName = "nutanix"
17+
// ServiceLoadBalancerName is the Service LoadBalancer config patch variable name.
18+
ServiceLoadBalancerVariableName = "serviceLoadBalancer"
1719
)

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,18 @@ spec:
201201
required:
202202
- strategy
203203
type: object
204+
serviceLoadBalancer:
205+
properties:
206+
provider:
207+
description: |-
208+
The LoadBalancer-type Service provider to deploy. Not required in infrastructures where
209+
the CCM acts as the provider.
210+
enum:
211+
- MetalLB
212+
type: string
213+
required:
214+
- provider
215+
type: object
204216
type: object
205217
aws:
206218
description: AWS cluster configuration.

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,18 @@ spec:
202202
required:
203203
- strategy
204204
type: object
205+
serviceLoadBalancer:
206+
properties:
207+
provider:
208+
description: |-
209+
The LoadBalancer-type Service provider to deploy. Not required in infrastructures where
210+
the CCM acts as the provider.
211+
enum:
212+
- MetalLB
213+
type: string
214+
required:
215+
- provider
216+
type: object
205217
type: object
206218
controlPlane:
207219
description: DockerNodeConfigSpec defines the desired state of DockerNodeSpec.

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,18 @@ spec:
202202
required:
203203
- strategy
204204
type: object
205+
serviceLoadBalancer:
206+
properties:
207+
provider:
208+
description: |-
209+
The LoadBalancer-type Service provider to deploy. Not required in infrastructures where
210+
the CCM acts as the provider.
211+
enum:
212+
- MetalLB
213+
type: string
214+
required:
215+
- provider
216+
type: object
205217
type: object
206218
controlPlane:
207219
description: NutanixNodeSpec defines the desired state of NutanixNodeSpec.

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

charts/cluster-api-runtime-extensions-nutanix/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ A Helm chart for cluster-api-runtime-extensions-nutanix
6262
| hooks.nfd.crsStrategy.defaultInstallationConfigMap.name | string | `"node-feature-discovery"` | |
6363
| hooks.nfd.helmAddonStrategy.defaultValueTemplateConfigMap.create | bool | `true` | |
6464
| hooks.nfd.helmAddonStrategy.defaultValueTemplateConfigMap.name | string | `"default-nfd-helm-values-template"` | |
65+
| hooks.serviceLoadBalancer.metalLB.defaultValueTemplateConfigMap.create | bool | `true` | |
66+
| hooks.serviceLoadBalancer.metalLB.defaultValueTemplateConfigMap.name | string | `"default-metallb-helm-values-template"` | |
6567
| hooks.virtualIP.kubeVip.defaultTemplateConfigMap.create | bool | `true` | |
6668
| hooks.virtualIP.kubeVip.defaultTemplateConfigMap.name | string | `"default-kube-vip-template"` | |
6769
| image.pullPolicy | string | `"IfNotPresent"` | |

charts/cluster-api-runtime-extensions-nutanix/templates/helm-config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ data:
1515
ChartName: cluster-autoscaler
1616
ChartVersion: 9.35.0
1717
RepositoryURL: https://kubernetes.github.io/autoscaler
18+
metallb: |
19+
ChartName: metallb
20+
ChartVersion: v0.14.5
21+
RepositoryURL: https://metallb.github.io/metallb
1822
nfd: |
1923
ChartName: node-feature-discovery
2024
ChartVersion: 0.15.2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Copyright 2023 D2iQ, Inc. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
{{- if .Values.hooks.serviceLoadBalancer.metalLB.defaultValueTemplateConfigMap.create }}
5+
apiVersion: v1
6+
kind: ConfigMap
7+
metadata:
8+
name: '{{ .Values.hooks.serviceLoadBalancer.metalLB.defaultValueTemplateConfigMap.name }}'
9+
data:
10+
values.yaml: |-
11+
controller:
12+
tolerations:
13+
- key: node-role.kubernetes.io/control-plane
14+
effect: NoSchedule
15+
operator: Exists
16+
- key: CriticalAddonsOnly
17+
operator: Exists
18+
- effect: NoExecute
19+
operator: Exists
20+
tolerationSeconds: 300
21+
speaker:
22+
tolerations:
23+
- key: node-role.kubernetes.io/control-plane
24+
effect: NoSchedule
25+
operator: Exists
26+
- key: CriticalAddonsOnly
27+
operator: Exists
28+
- effect: NoExecute
29+
operator: Exists
30+
tolerationSeconds: 300
31+
{{- end -}}

charts/cluster-api-runtime-extensions-nutanix/values.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,11 @@ hooks:
7171
defaultValueTemplateConfigMap:
7272
create: true
7373
name: default-cluster-autoscaler-helm-values-template
74-
74+
serviceLoadBalancer:
75+
metalLB:
76+
defaultValueTemplateConfigMap:
77+
create: true
78+
name: default-metallb-helm-values-template
7579
virtualIP:
7680
kubeVip:
7781
defaultTemplateConfigMap:

0 commit comments

Comments
 (0)