From 24e281fdffffad7dca0fa75fccd4b42e31109ba3 Mon Sep 17 00:00:00 2001 From: Moath Qasim Date: Wed, 28 Aug 2024 11:22:19 +0200 Subject: [PATCH] Add static up support for KubeVirt in KubeOVN (#1851) * add static up support for KubeVirt in KubeOVN * fix unit tests Signed-off-by: moadqassem --------- Signed-off-by: moadqassem --- pkg/cloudprovider/provider/kubevirt/provider.go | 8 ++++---- .../provider/kubevirt/testdata/affinity-no-values.yaml | 2 ++ .../provider/kubevirt/testdata/affinity.yaml | 2 ++ .../provider/kubevirt/testdata/custom-local-disk.yaml | 2 ++ .../provider/kubevirt/testdata/http-image-source.yaml | 2 ++ .../kubevirt/testdata/instancetype-preference-custom.yaml | 2 ++ .../testdata/instancetype-preference-standard.yaml | 2 ++ .../provider/kubevirt/testdata/nominal-case.yaml | 2 ++ .../provider/kubevirt/testdata/pvc-image-source.yaml | 2 ++ .../kubevirt/testdata/registry-image-source-pod.yaml | 2 ++ .../provider/kubevirt/testdata/registry-image-source.yaml | 2 ++ .../provider/kubevirt/testdata/secondary-disks.yaml | 2 ++ .../kubevirt/testdata/topologyspreadconstraints.yaml | 2 ++ 13 files changed, 28 insertions(+), 4 deletions(-) diff --git a/pkg/cloudprovider/provider/kubevirt/provider.go b/pkg/cloudprovider/provider/kubevirt/provider.go index 3ae9f600a..ef39118e1 100644 --- a/pkg/cloudprovider/provider/kubevirt/provider.go +++ b/pkg/cloudprovider/provider/kubevirt/provider.go @@ -637,17 +637,17 @@ func (p *provider) newVirtualMachine(_ context.Context, c *Config, pc *providerc var ( dataVolumeName = machine.Name - annotations map[string]string + annotations = map[string]string{} ) // Add machineName as prefix to secondaryDisks. addPrefixToSecondaryDisk(c.SecondaryDisks, dataVolumeName) if pc.OperatingSystem == providerconfigtypes.OperatingSystemFlatcar { - annotations = map[string]string{ - "kubevirt.io/ignitiondata": userdata, - } + annotations["kubevirt.io/ignitiondata"] = userdata } + annotations["ovn.kubernetes.io/allow_live_migration"] = "true" + defaultBridgeNetwork, err := defaultBridgeNetwork(macAddressGetter) if err != nil { return nil, fmt.Errorf("could not compute a random MAC address") diff --git a/pkg/cloudprovider/provider/kubevirt/testdata/affinity-no-values.yaml b/pkg/cloudprovider/provider/kubevirt/testdata/affinity-no-values.yaml index 7d01a42c7..bac6e7a46 100644 --- a/pkg/cloudprovider/provider/kubevirt/testdata/affinity-no-values.yaml +++ b/pkg/cloudprovider/provider/kubevirt/testdata/affinity-no-values.yaml @@ -28,6 +28,8 @@ spec: runStrategy: Once template: metadata: + annotations: + "ovn.kubernetes.io/allow_live_migration": "true" labels: cluster.x-k8s.io/cluster-name: cluster-name cluster.x-k8s.io/role: worker diff --git a/pkg/cloudprovider/provider/kubevirt/testdata/affinity.yaml b/pkg/cloudprovider/provider/kubevirt/testdata/affinity.yaml index a28aded56..7f1889466 100644 --- a/pkg/cloudprovider/provider/kubevirt/testdata/affinity.yaml +++ b/pkg/cloudprovider/provider/kubevirt/testdata/affinity.yaml @@ -28,6 +28,8 @@ spec: runStrategy: Once template: metadata: + annotations: + "ovn.kubernetes.io/allow_live_migration": "true" labels: cluster.x-k8s.io/cluster-name: cluster-name cluster.x-k8s.io/role: worker diff --git a/pkg/cloudprovider/provider/kubevirt/testdata/custom-local-disk.yaml b/pkg/cloudprovider/provider/kubevirt/testdata/custom-local-disk.yaml index b77494b63..1d761053c 100644 --- a/pkg/cloudprovider/provider/kubevirt/testdata/custom-local-disk.yaml +++ b/pkg/cloudprovider/provider/kubevirt/testdata/custom-local-disk.yaml @@ -29,6 +29,8 @@ spec: template: metadata: creationTimestamp: null + annotations: + "ovn.kubernetes.io/allow_live_migration": "true" labels: cluster.x-k8s.io/cluster-name: cluster-name cluster.x-k8s.io/role: worker diff --git a/pkg/cloudprovider/provider/kubevirt/testdata/http-image-source.yaml b/pkg/cloudprovider/provider/kubevirt/testdata/http-image-source.yaml index caef1ed52..c5125c087 100644 --- a/pkg/cloudprovider/provider/kubevirt/testdata/http-image-source.yaml +++ b/pkg/cloudprovider/provider/kubevirt/testdata/http-image-source.yaml @@ -28,6 +28,8 @@ spec: template: metadata: creationTimestamp: null + annotations: + "ovn.kubernetes.io/allow_live_migration": "true" labels: kubevirt.io/vm: http-image-source cluster.x-k8s.io/cluster-name: cluster-name diff --git a/pkg/cloudprovider/provider/kubevirt/testdata/instancetype-preference-custom.yaml b/pkg/cloudprovider/provider/kubevirt/testdata/instancetype-preference-custom.yaml index ba699302e..a27fc8674 100644 --- a/pkg/cloudprovider/provider/kubevirt/testdata/instancetype-preference-custom.yaml +++ b/pkg/cloudprovider/provider/kubevirt/testdata/instancetype-preference-custom.yaml @@ -34,6 +34,8 @@ spec: name: custom-pref template: metadata: + annotations: + "ovn.kubernetes.io/allow_live_migration": "true" labels: cluster.x-k8s.io/cluster-name: cluster-name cluster.x-k8s.io/role: worker diff --git a/pkg/cloudprovider/provider/kubevirt/testdata/instancetype-preference-standard.yaml b/pkg/cloudprovider/provider/kubevirt/testdata/instancetype-preference-standard.yaml index 1f54c87a7..718e23d38 100644 --- a/pkg/cloudprovider/provider/kubevirt/testdata/instancetype-preference-standard.yaml +++ b/pkg/cloudprovider/provider/kubevirt/testdata/instancetype-preference-standard.yaml @@ -34,6 +34,8 @@ spec: template: metadata: creationTimestamp: null + annotations: + "ovn.kubernetes.io/allow_live_migration": "true" labels: cluster.x-k8s.io/cluster-name: cluster-name cluster.x-k8s.io/role: worker diff --git a/pkg/cloudprovider/provider/kubevirt/testdata/nominal-case.yaml b/pkg/cloudprovider/provider/kubevirt/testdata/nominal-case.yaml index 24afa309c..bb65126cf 100644 --- a/pkg/cloudprovider/provider/kubevirt/testdata/nominal-case.yaml +++ b/pkg/cloudprovider/provider/kubevirt/testdata/nominal-case.yaml @@ -28,6 +28,8 @@ spec: template: metadata: creationTimestamp: null + annotations: + "ovn.kubernetes.io/allow_live_migration": "true" labels: cluster.x-k8s.io/cluster-name: cluster-name cluster.x-k8s.io/role: worker diff --git a/pkg/cloudprovider/provider/kubevirt/testdata/pvc-image-source.yaml b/pkg/cloudprovider/provider/kubevirt/testdata/pvc-image-source.yaml index 978213ec3..20fd7a4ee 100644 --- a/pkg/cloudprovider/provider/kubevirt/testdata/pvc-image-source.yaml +++ b/pkg/cloudprovider/provider/kubevirt/testdata/pvc-image-source.yaml @@ -29,6 +29,8 @@ spec: template: metadata: creationTimestamp: null + annotations: + "ovn.kubernetes.io/allow_live_migration": "true" labels: kubevirt.io/vm: pvc-image-source cluster.x-k8s.io/cluster-name: cluster-name diff --git a/pkg/cloudprovider/provider/kubevirt/testdata/registry-image-source-pod.yaml b/pkg/cloudprovider/provider/kubevirt/testdata/registry-image-source-pod.yaml index 9a8115c1d..7c047af05 100644 --- a/pkg/cloudprovider/provider/kubevirt/testdata/registry-image-source-pod.yaml +++ b/pkg/cloudprovider/provider/kubevirt/testdata/registry-image-source-pod.yaml @@ -29,6 +29,8 @@ spec: template: metadata: creationTimestamp: null + annotations: + "ovn.kubernetes.io/allow_live_migration": "true" labels: kubevirt.io/vm: registry-image-source-pod cluster.x-k8s.io/cluster-name: cluster-name diff --git a/pkg/cloudprovider/provider/kubevirt/testdata/registry-image-source.yaml b/pkg/cloudprovider/provider/kubevirt/testdata/registry-image-source.yaml index ee0548b09..df5dedac2 100644 --- a/pkg/cloudprovider/provider/kubevirt/testdata/registry-image-source.yaml +++ b/pkg/cloudprovider/provider/kubevirt/testdata/registry-image-source.yaml @@ -29,6 +29,8 @@ spec: template: metadata: creationTimestamp: null + annotations: + "ovn.kubernetes.io/allow_live_migration": "true" labels: kubevirt.io/vm: registry-image-source cluster.x-k8s.io/cluster-name: cluster-name diff --git a/pkg/cloudprovider/provider/kubevirt/testdata/secondary-disks.yaml b/pkg/cloudprovider/provider/kubevirt/testdata/secondary-disks.yaml index 0ce57a4b7..bea429e6f 100644 --- a/pkg/cloudprovider/provider/kubevirt/testdata/secondary-disks.yaml +++ b/pkg/cloudprovider/provider/kubevirt/testdata/secondary-disks.yaml @@ -54,6 +54,8 @@ spec: template: metadata: creationTimestamp: null + annotations: + "ovn.kubernetes.io/allow_live_migration": "true" labels: cluster.x-k8s.io/cluster-name: cluster-name cluster.x-k8s.io/role: worker diff --git a/pkg/cloudprovider/provider/kubevirt/testdata/topologyspreadconstraints.yaml b/pkg/cloudprovider/provider/kubevirt/testdata/topologyspreadconstraints.yaml index 363460724..965429429 100644 --- a/pkg/cloudprovider/provider/kubevirt/testdata/topologyspreadconstraints.yaml +++ b/pkg/cloudprovider/provider/kubevirt/testdata/topologyspreadconstraints.yaml @@ -28,6 +28,8 @@ spec: template: metadata: creationTimestamp: null + annotations: + "ovn.kubernetes.io/allow_live_migration": "true" labels: cluster.x-k8s.io/cluster-name: cluster-name cluster.x-k8s.io/role: worker