kubernetes-sigs/image-builder

Unable to build images with qemu

cunningr opened this issue · 3 comments

What steps did you take and what happened:

  1. Clone this repo on main into the latest hashicorp/packer docker container from Dockerhub
  2. Run make build-qemu-ubuntu-2204 inside images/capi
  3. Packer throws an error about not having the qemu provider.

I believe we just need a provider file config.pkr.hcl in images/capi/packer/qemu to declare the provider:

packer {
  required_plugins {
    qemu = {
      version = "~> 1"
      source  = "github.com/hashicorp/qemu"
    }
  }
}

What did you expect to happen:

The provider should be installed automatically.

Anything else you would like to add:
[Miscellaneous information that will assist in solving the issue.]

Environment:

Project (Image Builder for Cluster API: qemu

Additional info for Image Builder for Cluster API related issues:

NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.17.0
PRETTY_NAME="Alpine Linux v3.17"
HOME_URL="https://alpinelinux.org/"
BUG_REPORT_URL="https://gitlab.alpinelinux.org/alpine/aports/-/issues"
/ # packer -v
1.8.5
<missing provider for qemu>

/kind bug
[One or more /area label. See https://github.com/kubernetes-sigs/cluster-api/labels?q=area for the list of labels]

@cunningr Are you sure the version of Packer you're using is 1.8.5? 😕 The in-built qemu provider was removed in v1.10.0 and the latest version supported by image-builder is v1.9.5 (due to the licence change).

apologies - you're right (I was trying to fix multiple things at the same time):

docker run --entrypoint /bin/sh -it hashicorp/packer:latest
/ # packer -v
Packer v1.10.0

I took the latest packer to try and satisfy the latest Ansible constraint 2.15.8:

https://github.com/kubernetes-sigs/image-builder/blob/main/images/capi/hack/ensure-ansible.sh#L26

but I still had to bump the apk repo version:

RUN sed -i 's/v3.18/v3.19/g' /etc/apk/repositories

Although it looks like image-builder should take care of installing packer for us *if it is not there. In our case we were starting FROM hashicorp/packer:latest so I guess we should fix this our end.

Thanks for your help!

No worries, you're not the first to hit this. I've opened #1379 to look at how we could handle this and restrict the versions allowed to try and avoid this confusion for others. :)

If you use our provided container image as the base (e.g. registry.k8s.io/scl-image-builder/cluster-node-image-builder-amd64:v0.1.22) it should contain all the versions you'd need. This is how I work with image-builder.