diff --git a/README.md b/README.md index 6fa1d79c..bc36c50c 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,7 @@ Flags: --json Instead of human-readable output, return JSON to stdout --local Run network performance tests with Server-Pods/Client-Pods on the same Node --vm Launch Virtual Machines instead of pods for client/servers + --vm-image string Use specified VM image (default "kubevirt/fedora-cloud-container-disk-demo:latest") --across Place the client and server across availability zones --all Run all tests scenarios - hostNet and podNetwork (if possible) --debug Enable debug log diff --git a/cmd/k8s-netperf/k8s-netperf.go b/cmd/k8s-netperf/k8s-netperf.go index 684ec270..790dea18 100644 --- a/cmd/k8s-netperf/k8s-netperf.go +++ b/cmd/k8s-netperf/k8s-netperf.go @@ -43,6 +43,7 @@ var ( acrossAZ bool full bool vm bool + vmimage string debug bool promURL string id string @@ -169,6 +170,7 @@ var rootCmd = &cobra.Command{ if vm { s.VM = true + s.VMImage = vmimage // Create a dynamic client if s.DClient == nil { dynClient, err := dynamic.NewForConfig(rconfig) @@ -509,6 +511,7 @@ func main() { rootCmd.Flags().BoolVar(&json, "json", false, "Instead of human-readable output, return JSON to stdout") rootCmd.Flags().BoolVar(&nl, "local", false, "Run network performance tests with Server-Pods/Client-Pods on the same Node") rootCmd.Flags().BoolVar(&vm, "vm", false, "Launch Virtual Machines instead of pods for client/servers") + rootCmd.Flags().StringVar(&vmimage, "vm-image", "kubevirt/fedora-cloud-container-disk-demo:latest", "Use specified VM image") rootCmd.Flags().BoolVar(&acrossAZ, "across", false, "Place the client and server across availability zones") rootCmd.Flags().BoolVar(&full, "all", false, "Run all tests scenarios - hostNet and podNetwork (if possible)") rootCmd.Flags().BoolVar(&debug, "debug", false, "Enable debug log") diff --git a/pkg/config/config.go b/pkg/config/config.go index 44a0cb62..4f1cb0ff 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -37,6 +37,7 @@ type PerfScenarios struct { HostNetwork bool Configs []Config VM bool + VMImage string VMHost string Udn bool ServerNodeInfo metrics.NodeInfo diff --git a/pkg/k8s/kubernetes.go b/pkg/k8s/kubernetes.go index 36e953a1..8daeb38f 100644 --- a/pkg/k8s/kubernetes.go +++ b/pkg/k8s/kubernetes.go @@ -527,7 +527,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) + _, err := CreateVMServer(perf.KClient, serverRole, serverRole, *podAff, *nodeAff, perf.VMImage) if err != nil { return err } @@ -552,7 +552,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) + host, err := CreateVMClient(perf.KClient, perf.ClientSet, perf.DClient, name, podAff, nodeAff, perf.VMImage) if err != nil { return err } diff --git a/pkg/k8s/kubevirt.go b/pkg/k8s/kubevirt.go index 6834ee4c..59b99e68 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) (string, error) { + dyn *dynamic.DynamicClient, name string, podAff *corev1.PodAntiAffinity, nodeAff *corev1.NodeAffinity, vmimage string) (string, error) { label := map[string]string{ "app": name, "role": name, @@ -196,7 +196,7 @@ runcmd: - curl -o /usr/bin/super-netperf https://raw.githubusercontent.com/cloud-bulldozer/k8s-netperf/main/containers/super-netperf - chmod 0777 /usr/bin/super-netperf `, ssh) - _, err = CreateVMI(kclient, name, label, b64.StdEncoding.EncodeToString([]byte(data)), *podAff, *nodeAff) + _, err = CreateVMI(kclient, name, label, b64.StdEncoding.EncodeToString([]byte(data)), *podAff, *nodeAff, vmimage) if err != nil { return "", err } @@ -213,7 +213,7 @@ runcmd: // 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) (*v1.VirtualMachineInstance, error) { + nodeAff corev1.NodeAffinity, vmimage string) (*v1.VirtualMachineInstance, error) { label := map[string]string{ "app": name, "role": role, @@ -252,12 +252,12 @@ runcmd: - iperf3 -s -p %d & - netserver & `, string(ssh), UperfServerCtlPort, IperfServerCtlPort) - return CreateVMI(client, name, label, b64.StdEncoding.EncodeToString([]byte(data)), podAff, nodeAff) + return CreateVMI(client, name, label, b64.StdEncoding.EncodeToString([]byte(data)), podAff, nodeAff, vmimage) } // CreateVMI creates the desired Virtual Machine instance with the cloud-init config with affinity. func CreateVMI(client *kubevirtv1.KubevirtV1Client, name string, label map[string]string, b64data string, podAff corev1.PodAntiAffinity, - nodeAff corev1.NodeAffinity) (*v1.VirtualMachineInstance, error) { + nodeAff corev1.NodeAffinity, vmimage string) (*v1.VirtualMachineInstance, error) { delSeconds := int64(0) mutliQ := true vmi, err := client.VirtualMachineInstances(namespace).Create(context.TODO(), &v1.VirtualMachineInstance{ @@ -307,7 +307,7 @@ func CreateVMI(client *kubevirtv1.KubevirtV1Client, name string, label map[strin Name: "disk0", VolumeSource: v1.VolumeSource{ ContainerDisk: &v1.ContainerDiskSource{ - Image: "kubevirt/fedora-cloud-container-disk-demo:latest", + Image: vmimage, }, }, },