@@ -21,6 +21,7 @@ import (
2121 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2222 clientset "k8s.io/client-go/kubernetes"
2323 "k8s.io/kubernetes/test/e2e/framework"
24+ e2enode "k8s.io/kubernetes/test/e2e/framework/node"
2425
2526 mnpapi "github.com/k8snetworkplumbingwg/multi-networkpolicy/pkg/apis/k8s.cni.cncf.io/v1beta1"
2627 mnpclient "github.com/k8snetworkplumbingwg/multi-networkpolicy/pkg/client/clientset/versioned/typed/k8s.cni.cncf.io/v1beta1"
@@ -502,6 +503,12 @@ var _ = Describe("Multi Homing", func() {
502503 )
503504 Expect (err ).NotTo (HaveOccurred ())
504505
506+ By ("Get two scheduable nodes and schedule client and server to be on distinct Nodes" )
507+ nodes , err := e2enode .GetBoundedReadySchedulableNodes (context .Background (), f .ClientSet , 2 )
508+ framework .ExpectNoError (err , "2 scheduable nodes are required" )
509+ clientPodConfig .nodeSelector = map [string ]string {nodeHostnameKey : nodes .Items [0 ].GetName ()}
510+ serverPodConfig .nodeSelector = map [string ]string {nodeHostnameKey : nodes .Items [1 ].GetName ()}
511+
505512 By ("instantiating the server pod" )
506513 serverPod , err := cs .CoreV1 ().Pods (serverPodConfig .namespace ).Create (
507514 context .Background (),
@@ -578,15 +585,13 @@ var _ = Describe("Multi Homing", func() {
578585 cidr : secondaryNetworkCIDR ,
579586 },
580587 podConfiguration {
581- attachments : []nadapi.NetworkSelectionElement {{Name : secondaryNetworkName }},
582- name : clientPodName ,
583- nodeSelector : map [string ]string {nodeHostnameKey : workerOneNodeName },
588+ attachments : []nadapi.NetworkSelectionElement {{Name : secondaryNetworkName }},
589+ name : clientPodName ,
584590 },
585591 podConfiguration {
586592 attachments : []nadapi.NetworkSelectionElement {{Name : secondaryNetworkName }},
587593 name : podName ,
588594 containerCmd : httpServerContainerCmd (port ),
589- nodeSelector : map [string ]string {nodeHostnameKey : workerTwoNodeName },
590595 },
591596 ),
592597 ginkgo .Entry (
@@ -649,15 +654,13 @@ var _ = Describe("Multi Homing", func() {
649654 cidr : strings .Join ([]string {netCIDR (secondaryNetworkCIDR , netPrefixLengthPerNode ), netCIDR (secondaryIPv6CIDR , netPrefixLengthIPv6PerNode )}, "," ),
650655 },
651656 podConfiguration {
652- attachments : []nadapi.NetworkSelectionElement {{Name : secondaryNetworkName }},
653- name : clientPodName ,
654- nodeSelector : map [string ]string {nodeHostnameKey : workerOneNodeName },
657+ attachments : []nadapi.NetworkSelectionElement {{Name : secondaryNetworkName }},
658+ name : clientPodName ,
655659 },
656660 podConfiguration {
657661 attachments : []nadapi.NetworkSelectionElement {{Name : secondaryNetworkName }},
658662 name : podName ,
659663 containerCmd : httpServerContainerCmd (port ),
660- nodeSelector : map [string ]string {nodeHostnameKey : workerTwoNodeName },
661664 },
662665 ),
663666 ginkgo .Entry (
@@ -708,15 +711,13 @@ var _ = Describe("Multi Homing", func() {
708711 cidr : secondaryIPv6CIDR ,
709712 },
710713 podConfiguration {
711- attachments : []nadapi.NetworkSelectionElement {{Name : secondaryNetworkName }},
712- name : clientPodName ,
713- nodeSelector : map [string ]string {nodeHostnameKey : workerOneNodeName },
714+ attachments : []nadapi.NetworkSelectionElement {{Name : secondaryNetworkName }},
715+ name : clientPodName ,
714716 },
715717 podConfiguration {
716718 attachments : []nadapi.NetworkSelectionElement {{Name : secondaryNetworkName }},
717719 name : podName ,
718720 containerCmd : httpServerContainerCmd (port ),
719- nodeSelector : map [string ]string {nodeHostnameKey : workerTwoNodeName },
720721 },
721722 ),
722723 ginkgo .Entry (
@@ -727,15 +728,13 @@ var _ = Describe("Multi Homing", func() {
727728 cidr : strings .Join ([]string {secondaryFlatL2NetworkCIDR , secondaryIPv6CIDR }, "," ),
728729 },
729730 podConfiguration {
730- attachments : []nadapi.NetworkSelectionElement {{Name : secondaryNetworkName }},
731- name : clientPodName ,
732- nodeSelector : map [string ]string {nodeHostnameKey : workerOneNodeName },
731+ attachments : []nadapi.NetworkSelectionElement {{Name : secondaryNetworkName }},
732+ name : clientPodName ,
733733 },
734734 podConfiguration {
735735 attachments : []nadapi.NetworkSelectionElement {{Name : secondaryNetworkName }},
736736 name : podName ,
737737 containerCmd : httpServerContainerCmd (port ),
738- nodeSelector : map [string ]string {nodeHostnameKey : workerTwoNodeName },
739738 },
740739 ),
741740 ginkgo .Entry (
@@ -747,15 +746,13 @@ var _ = Describe("Multi Homing", func() {
747746 vlanID : localnetVLANID ,
748747 },
749748 podConfiguration {
750- attachments : []nadapi.NetworkSelectionElement {{Name : secondaryNetworkName }},
751- name : clientPodName ,
752- nodeSelector : map [string ]string {nodeHostnameKey : workerOneNodeName },
749+ attachments : []nadapi.NetworkSelectionElement {{Name : secondaryNetworkName }},
750+ name : clientPodName ,
753751 },
754752 podConfiguration {
755753 attachments : []nadapi.NetworkSelectionElement {{Name : secondaryNetworkName }},
756754 name : podName ,
757755 containerCmd : httpServerContainerCmd (port ),
758- nodeSelector : map [string ]string {nodeHostnameKey : workerTwoNodeName },
759756 },
760757 ),
761758 ginkgo .Entry (
@@ -768,14 +765,12 @@ var _ = Describe("Multi Homing", func() {
768765 podConfiguration {
769766 attachments : []nadapi.NetworkSelectionElement {{Name : secondaryNetworkName }},
770767 name : clientPodName ,
771- nodeSelector : map [string ]string {nodeHostnameKey : workerOneNodeName },
772768 isPrivileged : true ,
773769 },
774770 podConfiguration {
775771 attachments : []nadapi.NetworkSelectionElement {{Name : secondaryNetworkName }},
776772 name : podName ,
777773 containerCmd : httpServerContainerCmd (port ),
778- nodeSelector : map [string ]string {nodeHostnameKey : workerTwoNodeName },
779774 isPrivileged : true ,
780775 },
781776 ),
@@ -791,8 +786,7 @@ var _ = Describe("Multi Homing", func() {
791786 Name : secondaryNetworkName ,
792787 IPRequest : []string {clientIP },
793788 }},
794- name : clientPodName ,
795- nodeSelector : map [string ]string {nodeHostnameKey : workerOneNodeName },
789+ name : clientPodName ,
796790 },
797791 podConfiguration {
798792 attachments : []nadapi.NetworkSelectionElement {{
@@ -801,7 +795,6 @@ var _ = Describe("Multi Homing", func() {
801795 }},
802796 name : podName ,
803797 containerCmd : httpServerContainerCmd (port ),
804- nodeSelector : map [string ]string {nodeHostnameKey : workerTwoNodeName },
805798 },
806799 ),
807800 ginkgo .Entry (
@@ -813,15 +806,13 @@ var _ = Describe("Multi Homing", func() {
813806 vlanID : localnetVLANID ,
814807 },
815808 podConfiguration {
816- attachments : []nadapi.NetworkSelectionElement {{Name : secondaryNetworkName }},
817- name : clientPodName ,
818- nodeSelector : map [string ]string {nodeHostnameKey : workerOneNodeName },
809+ attachments : []nadapi.NetworkSelectionElement {{Name : secondaryNetworkName }},
810+ name : clientPodName ,
819811 },
820812 podConfiguration {
821813 attachments : []nadapi.NetworkSelectionElement {{Name : secondaryNetworkName }},
822814 name : podName ,
823815 containerCmd : httpServerContainerCmd (port ),
824- nodeSelector : map [string ]string {nodeHostnameKey : workerTwoNodeName },
825816 },
826817 ),
827818 ginkgo .Entry (
@@ -833,28 +824,26 @@ var _ = Describe("Multi Homing", func() {
833824 vlanID : localnetVLANID ,
834825 },
835826 podConfiguration {
836- attachments : []nadapi.NetworkSelectionElement {{Name : secondaryNetworkName }},
837- name : clientPodName ,
838- nodeSelector : map [string ]string {nodeHostnameKey : workerOneNodeName },
827+ attachments : []nadapi.NetworkSelectionElement {{Name : secondaryNetworkName }},
828+ name : clientPodName ,
839829 },
840830 podConfiguration {
841831 attachments : []nadapi.NetworkSelectionElement {{Name : secondaryNetworkName }},
842832 name : podName ,
843833 containerCmd : httpServerContainerCmd (port ),
844- nodeSelector : map [string ]string {nodeHostnameKey : workerTwoNodeName },
845834 },
846835 ),
847836 )
848837
849838 Context ("localnet OVN-K secondary network" , func () {
850839 const (
851- clientPodName = "client-pod"
852- nodeHostnameKey = "kubernetes.io/hostname"
853- servicePort = 9000
854- dockerNetworkName = "underlay"
855- underlayServiceIP = "60.128.0.1"
856- secondaryInterfaceName = "eth1"
857- expectedOriginalMTU = 1200
840+ clientPodName = "client-pod"
841+ nodeHostnameKey = "kubernetes.io/hostname"
842+ servicePort uint16 = 9000
843+ dockerNetworkName = "underlay"
844+ underlayServiceIP = "60.128.0.1"
845+ secondaryInterfaceName = "eth1"
846+ expectedOriginalMTU = 1200
858847 )
859848
860849 var netConfig networkAttachmentConfig
0 commit comments