Skip to content

Commit

Permalink
containerdisks/ WORKSPACE, BUILD.bazel: add new image
Browse files Browse the repository at this point in the history
Add customized container-disk for sriov lane tests

- WORKSPACE: add 'container_pull' rule

- containerimages/container-disk-images.md:
  How to create customize container-disk image
  and use it in tests.

  New image details

- containerimages/BUILD.bazel: add 'container_image' rule

Signed-off-by: Or Mergi <[email protected]>
  • Loading branch information
ormergi committed Aug 25, 2020
1 parent a961eb1 commit 423b389
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 0 deletions.
9 changes: 9 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,15 @@ container_pull(
repository = "library/fedora",
)

# Pull fedora 32 customize container-disk
container_pull(
name = "fedora_sriov_lane",
digest = "sha256:2d332d28863d0e415d58e335e836bd4f8a8c714e7a9d1f8f87418ef3db7c0afb",
registry = "index.docker.io",
repository = "kubevirt/fedora-sriov-testing",
#tag = "32",
)

# Pull base image libvirt
container_pull(
name = "libvirt",
Expand Down
13 changes: 13 additions & 0 deletions containerimages/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,16 @@ container_image(
files = ["@virtio_win_image//file"],
visibility = ["//visibility:public"],
)

container_image(
name = "fedora-sriov-lane-container-disk-image",
architecture = select({
"@io_bazel_rules_go//go/platform:linux_ppc64le": "ppc64le",
"//conditions:default": "amd64",
}),
base = select({
"@io_bazel_rules_go//go/platform:linux_ppc64le": "@fedora_sriov_lane_ppc64le//image",
"//conditions:default": "@fedora_sriov_lane//image",
}),
visibility = ["//visibility:public"],
)
100 changes: 100 additions & 0 deletions containerimages/container-disk-images.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,103 @@ The following images stored at `dockerhub.com/kubevirt` and can be used in Kubev

- **fedora-cloud-container-disk-demo**
Fedora cloud edition image.

- **fedora-sriov-lane-container-disk**
Fedora cloud edition image with contains all necessary configuration and drivers for sriov lane tests.
- This image contained the packages:
- kernel-modules (includes sriov drivers)
- qemu-guest-agent
- Configurations:
- Enable and start qemu-guest-agent
- Load kernel modules needed for sriov
mlx4, mlx5, i40e, igb

## How to create new customized container-disk for tests

Work-in-progress PR to automate this process https://github.com/kubevirt/kubevirtci/pull/428

Customize an image can be done by:
- Editing the image with `virt-customize`
Adding new package to an image for example:
`virt-customize -a "fedora32.qcow2" --install dpdk`

- Spin-up live VM with the image you want using `virt-install`
Once the VM is up apply the changes you want and when done
shut down the VM gracefully with `sudo shutdown -h now`

Next, it is necessary to prepare the image so there will be no unique files or configurations
so each VM that will be created with the new image will have unique machine-id, mac-address etc..
We can do that with `virt-sysprep`:
```bash
virt-sysprep -a fedora32.qcow --operations machine-id,bash-history,logfiles,tmp-files,net-hostname,net-hwaddr
```

Once the image is ready it is necessary to convert it to
container image with `kubevirt/container-disk-v1alpha` layer,
so KubeVirt VM's can consume it according to
https://github.com/kubevirt/kubevirt/blob/master/docs/container-register-disks.md

```bash
cat > Dockerfile <<EOF
FROM kubevirt/container-disk-v1alpha
ADD fedora32.qcow2 /disk/
EOF

docker build -t kubevirt/fedora-sriov-testing:latest .
```


## Use image in Kubevirt tests

First we need pull the image from the remote registry (or local registry) by adding `container_pull` rule to `WORKSPACE` file:
```bash
container_pull(
name = "fedora_sriov_lane",
# digest = ""
registry = "localhost:5000",
repository = "kubevirt/fedora-sriov-testing",
tag = "latest",
)
```
Once you verified the image works reach out to kubevirt CI maintainers and ask to upload the new image
then update the `container_pull` rule accordingly.
```bash
container_pull(
name = "fedora_sriov_lane",
digest = ""
registry = "index.docker.io",
repository = "kubevirt/fedora-sriov-testing",
# tag = "32",
)
```

Next we need to add `contaier_image` rule for the new image to `containerdisks/BUILD.bazel` file;
```bash
container_image(
name = "fedora-sriov-lane-container-disk-image",
architecture = select({
"@io_bazel_rules_go//go/platform:linux_ppc64le": "ppc64le",
"//conditions:default": "amd64",
}),
base = select({
"@io_bazel_rules_go//go/platform:linux_ppc64le": "@fedora_sriov_lane_ppc64le//image",
"//conditions:default": "@fedora_sriov_lane//image",
}),
visibility = ["//visibility:public"],
)
```

Then add new line for the container_bundle rule at the pojects`BUILD.bazel` file
```bash
container_bundle(
name = "build-other-images",
images = {
...
"$(container_prefix)/$(image_prefix)fedora-sriov-lane-container-disk:$(container_tag)": "//containerimages:fedora-extended-container-disk-image",
...
}
)
```

Finally, in order to use the image in tests suite it is necessary to add it to `tests/containerdisks/containerdisks.go` file.

0 comments on commit 423b389

Please sign in to comment.