Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow users to override VM image #160

Merged
merged 1 commit into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions cmd/k8s-netperf/k8s-netperf.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ var (
acrossAZ bool
full bool
vm bool
vmimage string
debug bool
promURL string
id string
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand Down
1 change: 1 addition & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type PerfScenarios struct {
HostNetwork bool
Configs []Config
VM bool
VMImage string
VMHost string
Udn bool
ServerNodeInfo metrics.NodeInfo
Expand Down
4 changes: 2 additions & 2 deletions pkg/k8s/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down
12 changes: 6 additions & 6 deletions pkg/k8s/kubevirt.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
}
Expand All @@ -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,
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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,
},
},
},
Expand Down
Loading