Skip to content

Commit

Permalink
document custom LXD images
Browse files Browse the repository at this point in the history
  • Loading branch information
neoaggelos committed Jun 26, 2024
1 parent a02fb39 commit 5956f96
Showing 1 changed file with 80 additions and 3 deletions.
83 changes: 80 additions & 3 deletions tests/integration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,86 @@ Then, run the tests with:
export TEST_SNAP=$PWD/k8s.snap
export TEST_SUBSTRATE=lxd

export TEST_LXD_IMAGE=ubuntu:22.04 # (optionally) specify which image to use for LXD containers
export TEST_LXD_PROFILE=k8s-integration # (optionally) specify profile name to configure
export TEST_SKIP_CLEANUP=1 # (optionally) do not destroy machines after tests finish
export TEST_LXD_IMAGE=ubuntu:22.04 # (optionally) specify which image to use for LXD containers
export TEST_LXD_PROFILE_NAME=k8s-integration # (optionally) specify profile name to configure
export TEST_SKIP_CLEANUP=1 # (optionally) do not destroy machines after tests finish

cd tests/integration && tox -e integration
```

When using LXD, it is possible to reduce the amount of steps needed to setup each container and sideload all OCI images. See [./lxd/setup-image.sh](./lxd/setup-image.sh) for details. For example, to build an image `k8s-e2e/ubuntu` based on `ubuntu:24.04`:

```bash
# build custom image 'k8s-e2e/ubuntu'
export TEST_SNAP=$PWD/k8s.snap
export BASE_IMAGE=ubuntu:24.04
export OUT_IMAGES_DIR=$PWD/k8s-e2e-images
export OUT_IMAGE_ALIAS=k8s-e2e/ubuntu
./tests/integration/lxd/setup-image.sh

# run tests using custom image
export TEST_SUBSTRATE=lxd
export TEST_LXD_IMAGE=k8s-e2e/ubuntu
export TEST_LXD_SIDELOAD_IMAGES_DIR=$PWD/k8s-e2e-images
cd tests/integration && tox -e integration
```

#### Running end to end tests on LXD containers for non-Ubuntu distributions

It is possible to use LXD to run the end to end tests with non-Ubuntu distributions, e.g. Debian or Alma Linux.

These distributions come without snapd installed out of the box, therefore they require building a custom image with snapd installed.

##### Debian 12

Build an image called `k8s-e2e/debian-12` with:

```bash
export TEST_SNAP=$PWD/k8s.snap
export BASE_IMAGE=images:debian/12
export BASE_DISTRO=debian
export OUT_IMAGES_DIR=$PWD/k8s-e2e-images
export OUT_IMAGE_ALIAS=k8s-e2e/debian-12

./tests/integration/lxd/setup-image.sh
```

Then, run the end to end tests with:

```bash
export TEST_SNAP=$PWD/k8s.snap
export TEST_SUBSTRATE=lxd
export TEST_LXD_IMAGE=k8s-e2e/debian-12
export TEST_LXD_SIDELOAD_IMAGES_DIR=$PWD/k8s-e2e-images

cd tests/integration && tox -e integration
```

##### AlmaLinux 9

Build an image called `k8s-e2e/almalinux-9` with:

```bash
export TEST_SNAP=$PWD/k8s.snap
export BASE_IMAGE=images:almalinux/9
export BASE_DISTRO=almalinux
export OUT_IMAGES_DIR=$PWD/k8s-e2e-images
export OUT_IMAGE_ALIAS=k8s-e2e/almalinux-9

./tests/integration/lxd/setup-image.sh
```

Then, run the end to end tests with:

```bash
export TEST_SNAP=$PWD/k8s.snap
export TEST_SUBSTRATE=lxd
export TEST_LXD_SIDELOAD_IMAGES_DIR=$PWD/k8s-e2e-images
export TEST_LXD_IMAGE=k8s-e2e/almalinux-9

# AlmaLinux needs a separate LXD profile
export TEST_LXD_PROFILE_NAME=k8s-integration-almalinux
export TEST_LXD_PROFILE="$(cat tests/integration/lxd/almalinux/lxd-profile.yaml)"

cd tests/integration && tox -e integration
```
Expand Down

0 comments on commit 5956f96

Please sign in to comment.