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

[traffic-gen-in-vm] Attach traffic-gen's ConfigMap to traffic gen VMI #148

Merged

Conversation

orelmisan
Copy link
Member

@orelmisan orelmisan commented Jul 19, 2023

In order to get the Trex configuration, the ConfigMap object generated by the checkup, should be attached to the traffic-gen VMI, and mounted inside the guest [1].

  1. Create a volume in the traffic gen VMI, referring to the to the traffic-gen's ConfigMap.
  2. Create a disk that refers to the above volume.
  3. Using cloud init, mount the above disk to the guest's file system.

The generated ConfigMap is currently empty, until a follow-up PR will fill it up.

Based on PR #147, please review only the last three commits.

[1] http://kubevirt.io/user-guide/virtual_machines/disks_and_volumes/#configmap

@orelmisan
Copy link
Member Author

Change: Rebase

In order to attach the TRex ConfigMap to the traffic gen VMI:
1. Add a function to attach a volume pointing to an existing ConfigMap
2. Add a function to add a disk pointing to the ConfigMap volume.

Signed-off-by: Orel Misan <[email protected]>
In order to mount the files from the TRex ConfigMap,
additional boot commands should be passed in cloudInit.

Enable the addition of boot commands to the function generating
the cloud init string.

Signed-off-by: Orel Misan <[email protected]>
@orelmisan
Copy link
Member Author

Change: Rebase

@orelmisan
Copy link
Member Author

Tested against an OpenShift Virtualization 4.14 cluster.

func WithConfigMapDisk(name, serial string) Option {
return func(vmi *kvcorev1.VirtualMachineInstance) {
vmi.Spec.Domain.Devices.Disks = append(vmi.Spec.Domain.Devices.Disks,
kvcorev1.Disk{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I ran it on the GUI it chose the sata bus. AFAIK it is not a default value so maybe we should hard code it here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some component in KubeVirt added the sata bus automatically.
The example doesn't use sata [1].

[1] http://kubevirt.io/user-guide/virtual_machines/disks_and_volumes/#configmap

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example is U/S. When I tried it on my D/S it didn't seem to work.
On the other hand I didn't really find a D/S document on it, so I rely on what the D/S GUI gave me as the "practical documentation"

In the end - if it works and the file is propagated, then maybe I did something wrong on my manual try, so we can continue, but please make sure it works on the D/S cluster.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works on the SNO.

@@ -70,13 +70,15 @@ func New(client kubeVirtVMIClient, namespace string, checkupConfig config.Config
const randomStringLen = 5
randomSuffix := rand.String(randomStringLen)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commit typo: ConfigMao

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.
Done.

@@ -65,15 +65,23 @@ func newVMIUnderTest(name string, checkupConfig config.Config) *kvcorev1.Virtual
return vmi.New(name, optionsToApply...)
}

func newTrafficGen(name string, checkupConfig config.Config) *kvcorev1.VirtualMachineInstance {
func newTrafficGen(name string, checkupConfig config.Config, configMapName string) *kvcorev1.VirtualMachineInstance {
const configDiskSerial = "DEADBEEF"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: DEADBEEF is usually used when you can only use HEX letters, so if you want you have more options..

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a smarter idea.
Feel free to suggest another value ;)

Copy link
Collaborator

@RamLavi RamLavi Jul 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

randomize?
again, only a nit, so I wouldn't mind keeping it the way it is..

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can always change it.
It has no affect on the user.

Pass the name of the ConfigMap when creating the traffic gen VMI.
Use it to attach the ConfigMap volume.

Add a disk to the traffic gen VMI, which will have the files from
the ConfigMap.

Add the required cloud init boot commands to mount the above disk [1].

[1] http://kubevirt.io/user-guide/virtual_machines/disks_and_volumes/#configmap

Signed-off-by: Orel Misan <[email protected]>
@orelmisan
Copy link
Member Author

Change: Fixed a typo in the last commit message.

Copy link
Collaborator

@RamLavi RamLavi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
/approve

@orelmisan orelmisan merged commit 10cb1ce into kiagnose:traffic-gen-in-vm Jul 19, 2023
4 checks passed
@orelmisan orelmisan deleted the attach_cm_to_traffic_gen branch July 19, 2023 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants