diff --git a/cmd/k8s-netperf/k8s-netperf.go b/cmd/k8s-netperf/k8s-netperf.go index 8b8b1d2..f24b04a 100644 --- a/cmd/k8s-netperf/k8s-netperf.go +++ b/cmd/k8s-netperf/k8s-netperf.go @@ -35,29 +35,30 @@ const index = "k8s-netperf" const retry = 3 var ( - cfgfile string - nl bool - clean bool - netperf bool - iperf3 bool - uperf bool - udn bool - acrossAZ bool - full bool - vm bool - vmimage string - debug bool - bridge string - bridgeNetwork string - promURL string - id string - searchURL string - showMetrics bool - tcpt float64 - json bool - version bool - csvArchive bool - searchIndex string + cfgfile string + nl bool + clean bool + netperf bool + iperf3 bool + uperf bool + udn bool + udnPluginBinding string + acrossAZ bool + full bool + vm bool + vmimage string + debug bool + bridge string + bridgeNetwork string + promURL string + id string + searchURL string + showMetrics bool + tcpt float64 + json bool + version bool + csvArchive bool + searchIndex string ) var rootCmd = &cobra.Command{ @@ -198,6 +199,9 @@ var rootCmd = &cobra.Command{ log.Error(err) } } + if udn { + s.UdnPluginBinding = udnPluginBinding + } } // Build the SUT (Deployments) @@ -468,7 +472,6 @@ func executeWorkload(nc config.Config, //when using a bridge } else if s.BridgeServerNetwork != "" { serverIP = strings.Split(s.BridgeServerNetwork, "/")[0] - } else { if hostNet { serverIP = s.ServerHost.Items[0].Status.PodIP @@ -568,6 +571,7 @@ func main() { rootCmd.Flags().BoolVar(&full, "all", false, "Run all tests scenarios - hostNet and podNetwork (if possible)") rootCmd.Flags().BoolVar(&debug, "debug", false, "Enable debug log") rootCmd.Flags().BoolVar(&udn, "udn", false, "Create and use a UDN called 'udn-l2-primary' as primary network.") + rootCmd.Flags().StringVar(&udnPluginBinding, "udnPluginBinding", "passt", "UDN with VMs only - the binding method of the UDN interface, select 'passt' or 'l2bridge'") rootCmd.Flags().StringVar(&bridge, "bridge", "", "Name of the NNCP to be used for creating bridge interface - VM only.") rootCmd.Flags().StringVar(&bridgeNetwork, "bridgeNetwork", "bridgeNetwork.json", "Json file for the network defined by the bridge interface - bridge should be enabled") rootCmd.Flags().StringVar(&promURL, "prom", "", "Prometheus URL") diff --git a/pkg/config/config.go b/pkg/config/config.go index 3408e55..b276820 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -40,6 +40,7 @@ type PerfScenarios struct { VMImage string VMHost string Udn bool + UdnPluginBinding string BridgeServerNetwork string BridgeClientNetwork string ServerNodeInfo metrics.NodeInfo diff --git a/pkg/k8s/kubernetes.go b/pkg/k8s/kubernetes.go index c31c72b..4d1b87c 100644 --- a/pkg/k8s/kubernetes.go +++ b/pkg/k8s/kubernetes.go @@ -151,8 +151,9 @@ func DeployL2Udn(dynamicClient *dynamic.DynamicClient) error { "spec": map[string]interface{}{ "topology": "Layer2", "layer2": map[string]interface{}{ - "role": "Primary", - "subnets": []string{"10.0.0.0/24", "2001:db8::/60"}, + "role": "Primary", + "subnets": []string{"10.0.0.0/24"}, + "ipamLifecycle": "Persistent", }, }, }, @@ -587,7 +588,7 @@ func ExtractUdnIp(s config.PerfScenarios) (string, error) { // launchServerVM will create the ServerVM with the specific node and pod affinity. func launchServerVM(perf *config.PerfScenarios, name string, podAff *corev1.PodAntiAffinity, nodeAff *corev1.NodeAffinity) error { - _, err := CreateVMServer(perf.KClient, serverRole, serverRole, *podAff, *nodeAff, perf.VMImage, perf.BridgeServerNetwork) + _, err := CreateVMServer(perf.KClient, serverRole, serverRole, *podAff, *nodeAff, perf.VMImage, perf.BridgeServerNetwork, perf.Udn, perf.UdnPluginBinding) if err != nil { return err } @@ -595,6 +596,7 @@ func launchServerVM(perf *config.PerfScenarios, name string, podAff *corev1.PodA if err != nil { return err } + if strings.Contains(name, "host") { perf.ServerHost, err = GetPods(perf.ClientSet, fmt.Sprintf("app=%s", serverRole)) if err != nil { @@ -612,7 +614,7 @@ func launchServerVM(perf *config.PerfScenarios, name string, podAff *corev1.PodA // launchClientVM will create the ClientVM with the specific node and pod affinity. func launchClientVM(perf *config.PerfScenarios, name string, podAff *corev1.PodAntiAffinity, nodeAff *corev1.NodeAffinity) error { - host, err := CreateVMClient(perf.KClient, perf.ClientSet, perf.DClient, name, podAff, nodeAff, perf.VMImage, perf.BridgeClientNetwork) + host, err := CreateVMClient(perf.KClient, perf.ClientSet, perf.DClient, name, podAff, nodeAff, perf.VMImage, perf.BridgeClientNetwork, perf.Udn, perf.UdnPluginBinding) if err != nil { return err } diff --git a/pkg/k8s/kubevirt.go b/pkg/k8s/kubevirt.go index 16c3956..38ef2fb 100644 --- a/pkg/k8s/kubevirt.go +++ b/pkg/k8s/kubevirt.go @@ -158,7 +158,7 @@ func exposeService(client *kubernetes.Clientset, dynamicClient *dynamic.DynamicC // CreateVMClient takes in the affinity rules and deploys the VMI func CreateVMClient(kclient *kubevirtv1.KubevirtV1Client, client *kubernetes.Clientset, - dyn *dynamic.DynamicClient, name string, podAff *corev1.PodAntiAffinity, nodeAff *corev1.NodeAffinity, vmimage string, bridgeNetwork string) (string, error) { + dyn *dynamic.DynamicClient, name string, podAff *corev1.PodAntiAffinity, nodeAff *corev1.NodeAffinity, vmimage string, bridgeNetwork string, udn bool, udnPluginBinding string) (string, error) { label := map[string]string{ "app": name, "role": name, @@ -232,6 +232,27 @@ runcmd: ethernets: eth1: addresses: [ %s ]`, bridgeNetwork) + } else if udn { + interfaces = []v1.Interface{ + { + Name: "primary-l2-net", + Binding: &v1.PluginBinding{ + Name: udnPluginBinding, + }, + }, + } + networks = []v1.Network{ + { + Name: "primary-l2-net", + NetworkSource: v1.NetworkSource{ + Pod: &v1.PodNetwork{}, + }, + }, + } + netData = `version: 2 +ethernets: + eth0: + dhcp4: true` } _, err = CreateVMI(kclient, name, label, b64.StdEncoding.EncodeToString([]byte(data)), *podAff, *nodeAff, vmimage, interfaces, networks, b64.StdEncoding.EncodeToString([]byte(netData))) if err != nil { @@ -250,7 +271,7 @@ ethernets: // CreateVMServer will take the pod and node affinity and deploy the VMI func CreateVMServer(client *kubevirtv1.KubevirtV1Client, name string, role string, podAff corev1.PodAntiAffinity, - nodeAff corev1.NodeAffinity, vmimage string, bridgeNetwork string) (*v1.VirtualMachineInstance, error) { + nodeAff corev1.NodeAffinity, vmimage string, bridgeNetwork string, udn bool, udnPluginBinding string) (*v1.VirtualMachineInstance, error) { label := map[string]string{ "app": name, "role": role, @@ -275,6 +296,7 @@ ssh_deletekeys: false password: fedora chpasswd: { expire: False } runcmd: + - export HOME=/home/fedora - dnf install -y --nodocs uperf iperf3 git ethtool - dnf install -y --nodocs automake gcc bc lksctp-tools-devel texinfo --enablerepo=* - git clone https://github.com/HewlettPackard/netperf.git @@ -325,6 +347,27 @@ runcmd: ethernets: eth1: addresses: [ %s ]`, bridgeNetwork) + } else if udn { + interfaces = []v1.Interface{ + { + Name: "primary-l2-net", + Binding: &v1.PluginBinding{ + Name: udnPluginBinding, + }, + }, + } + networks = []v1.Network{ + { + Name: "primary-l2-net", + NetworkSource: v1.NetworkSource{ + Pod: &v1.PodNetwork{}, + }, + }, + } + netData = `version: 2 +ethernets: + eth0: + dhcp4: true` } return CreateVMI(client, name, label, b64.StdEncoding.EncodeToString([]byte(data)), podAff, nodeAff, vmimage, interfaces, networks, b64.StdEncoding.EncodeToString([]byte(netData))) }