Skip to content

Commit b07af66

Browse files
committed
Add Octavia OVN Provider Support
This commit adds support for Octavia OVN Provider. Changes includes adding provider option in apiServerLoadBalancer and when it is set to OVN, use SOURCE_IP_PORT as load balancing algorithm.
1 parent 3c12468 commit b07af66

File tree

12 files changed

+94
-33
lines changed

12 files changed

+94
-33
lines changed

api/v1alpha3/conversion_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ func TestFuzzyConversion(t *testing.T) {
234234
v1alpha7Cluster.Spec.AllowAllInClusterTraffic = false
235235
v1alpha7Cluster.Spec.DisableAPIServerFloatingIP = false
236236
v1alpha7Cluster.Spec.APIServerLoadBalancer.AllowedCIDRs = nil
237+
v1alpha7Cluster.Spec.APIServerLoadBalancer.Provider = ""
237238
if v1alpha7Cluster.Spec.Bastion != nil {
238239
v1alpha7Cluster.Spec.Bastion.Instance.ImageUUID = ""
239240
v1alpha7Cluster.Spec.Bastion.Instance.Ports = nil

api/v1alpha4/conversion_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ func TestFuzzyConversion(t *testing.T) {
335335
v1alpha7Cluster.ObjectMeta.Annotations = map[string]string{}
336336

337337
v1alpha7Cluster.Spec.APIServerLoadBalancer.AllowedCIDRs = nil
338+
v1alpha7Cluster.Spec.APIServerLoadBalancer.Provider = ""
338339

339340
v1alpha7Cluster.Spec.ControlPlaneOmitAvailabilityZone = false
340341

@@ -413,6 +414,7 @@ func TestFuzzyConversion(t *testing.T) {
413414
v1alpha7ClusterTemplate.ObjectMeta.Annotations = map[string]string{}
414415

415416
v1alpha7ClusterTemplate.Spec.Template.Spec.APIServerLoadBalancer.AllowedCIDRs = nil
417+
v1alpha7ClusterTemplate.Spec.Template.Spec.APIServerLoadBalancer.Provider = ""
416418

417419
v1alpha7ClusterTemplate.Spec.Template.Spec.ControlPlaneOmitAvailabilityZone = false
418420

api/v1alpha5/conversion.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,3 +235,8 @@ func Convert_Slice_v1alpha7_Network_To_Slice_v1alpha5_Network(in *[]infrav1.Netw
235235
func Convert_v1alpha5_OpenStackMachineSpec_To_v1alpha7_OpenStackMachineSpec(in *OpenStackMachineSpec, out *infrav1.OpenStackMachineSpec, s conversion.Scope) error {
236236
return autoConvert_v1alpha5_OpenStackMachineSpec_To_v1alpha7_OpenStackMachineSpec(in, out, s)
237237
}
238+
239+
func Convert_v1alpha7_APIServerLoadBalancer_To_v1alpha5_APIServerLoadBalancer(in *infrav1.APIServerLoadBalancer, out *APIServerLoadBalancer, s conversion.Scope) error {
240+
// Provider have been added in v1alpha7 but have no equivalent in v1alpha5
241+
return autoConvert_v1alpha7_APIServerLoadBalancer_To_v1alpha5_APIServerLoadBalancer(in, out, s)
242+
}

api/v1alpha5/zz_generated.conversion.go

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

api/v1alpha6/conversion.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,3 +235,8 @@ func (r *OpenStackMachineTemplateList) ConvertFrom(srcRaw ctrlconversion.Hub) er
235235
func Convert_v1alpha6_OpenStackMachineSpec_To_v1alpha7_OpenStackMachineSpec(in *OpenStackMachineSpec, out *infrav1.OpenStackMachineSpec, s conversion.Scope) error {
236236
return autoConvert_v1alpha6_OpenStackMachineSpec_To_v1alpha7_OpenStackMachineSpec(in, out, s)
237237
}
238+
239+
func Convert_v1alpha7_APIServerLoadBalancer_To_v1alpha6_APIServerLoadBalancer(in *infrav1.APIServerLoadBalancer, out *APIServerLoadBalancer, s conversion.Scope) error {
240+
// Provider have been added in v1alpha7 but have no equivalent in v1alpha6
241+
return autoConvert_v1alpha7_APIServerLoadBalancer_To_v1alpha6_APIServerLoadBalancer(in, out, s)
242+
}

api/v1alpha6/conversion_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@ package v1alpha6
1919
import (
2020
"testing"
2121

22+
fuzz "github.com/google/gofuzz"
2223
"github.com/onsi/gomega"
24+
"k8s.io/apimachinery/pkg/api/apitesting/fuzzer"
2325
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
26+
runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer"
2427
utilconversion "sigs.k8s.io/cluster-api/util/conversion"
2528
ctrlconversion "sigs.k8s.io/controller-runtime/pkg/conversion"
2629

@@ -35,16 +38,33 @@ func TestFuzzyConversion(t *testing.T) {
3538
delete(obj.GetAnnotations(), utilconversion.DataAnnotation)
3639
}
3740

41+
fuzzerFuncs := func(_ runtimeserializer.CodecFactory) []interface{} {
42+
return []interface{}{
43+
func(v1alpha7Cluster *infrav1.OpenStackCluster, c fuzz.Continue) {
44+
c.FuzzNoCustom(v1alpha7Cluster)
45+
46+
v1alpha7Cluster.Spec.APIServerLoadBalancer.Provider = ""
47+
},
48+
func(v1alpha7ClusterTemplate *infrav1.OpenStackClusterTemplate, c fuzz.Continue) {
49+
c.FuzzNoCustom(v1alpha7ClusterTemplate)
50+
51+
v1alpha7ClusterTemplate.Spec.Template.Spec.APIServerLoadBalancer.Provider = ""
52+
},
53+
}
54+
}
55+
3856
t.Run("for OpenStackCluster", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{
3957
Hub: &infrav1.OpenStackCluster{},
4058
Spoke: &OpenStackCluster{},
4159
HubAfterMutation: ignoreDataAnnotation,
60+
FuzzerFuncs: []fuzzer.FuzzerFuncs{fuzzerFuncs},
4261
}))
4362

4463
t.Run("for OpenStackClusterTemplate", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{
4564
Hub: &infrav1.OpenStackClusterTemplate{},
4665
Spoke: &OpenStackClusterTemplate{},
4766
HubAfterMutation: ignoreDataAnnotation,
67+
FuzzerFuncs: []fuzzer.FuzzerFuncs{fuzzerFuncs},
4868
}))
4969

5070
t.Run("for OpenStackMachine", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{

api/v1alpha6/zz_generated.conversion.go

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

api/v1alpha7/types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,8 @@ type APIServerLoadBalancer struct {
323323
AdditionalPorts []int `json:"additionalPorts,omitempty"`
324324
// AllowedCIDRs restrict access to all API-Server listeners to the given address CIDRs.
325325
AllowedCIDRs []string `json:"allowedCidrs,omitempty"`
326+
// Octavia Provider Used to create load balancer
327+
Provider string `json:"provider,omitempty"`
326328
}
327329

328330
// ValueSpec represents a single value_spec key-value pair.

config/crd/bases/infrastructure.cluster.x-k8s.io_openstackclusters.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6174,6 +6174,9 @@ spec:
61746174
description: Enabled defines whether a load balancer should be
61756175
created.
61766176
type: boolean
6177+
provider:
6178+
description: Octavia Provider Used to create load balancer
6179+
type: string
61776180
type: object
61786181
apiServerPort:
61796182
description: APIServerPort is the port on which the listener on the

config/crd/bases/infrastructure.cluster.x-k8s.io_openstackclustertemplates.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2274,6 +2274,9 @@ spec:
22742274
description: Enabled defines whether a load balancer should
22752275
be created.
22762276
type: boolean
2277+
provider:
2278+
description: Octavia Provider Used to create load balancer
2279+
type: string
22772280
type: object
22782281
apiServerPort:
22792282
description: APIServerPort is the port on which the listener

0 commit comments

Comments
 (0)