ci: Implement build step for CSI driver

This fully implements the compilation step for csi-kata-directvolume.
This component can now be built by the CI running:

 $ cd tools/packaging/kata-deploy/local-build
 $ make csi-kata-directvolume-tarball

A couple notes:

 * When installing the binary, we rename it from directvolplugin to
   csi-kata-directvolume on the fly to make it more readable.
 * We add go to the tools builder Dockerfile to support building this
   tool.
 * I've noticed the file install_libseccomp.sh gets created by the build
   process so I've added it to a .gitignore.

Signed-off-by: Aurélien Bombo <abombo@microsoft.com>
This commit is contained in:
Aurélien Bombo
2024-11-21 15:46:24 -06:00
parent 0f6113a743
commit fb87bf221f
6 changed files with 23 additions and 2 deletions

View File

@@ -0,0 +1 @@
bin/

View File

@@ -99,7 +99,7 @@ cloud-hypervisor-glibc-tarball:
${MAKE} $@-build
csi-kata-directvolume-tarball: copy-scripts-for-the-tools-build
$(call DUMMY,$@)
${MAKE} $@-build
firecracker-tarball:
${MAKE} $@-build

View File

@@ -99,6 +99,7 @@ options:
coco-guest-components
cloud-hypervisor
cloud-hypervisor-glibc
csi-kata-directvolume
firecracker
genpolicy
kata-ctl
@@ -1022,6 +1023,7 @@ install_tools_helper() {
tool_binary=${tool}
[ ${tool} = "agent-ctl" ] && tool_binary="kata-agent-ctl"
[ ${tool} = "csi-kata-directvolume" ] && tool_binary="directvolplugin"
[ ${tool} = "trace-forwarder" ] && tool_binary="kata-trace-forwarder"
binary=$(find ${repo_root_dir}/src/tools/${tool}/ -type f -name ${tool_binary})
@@ -1043,6 +1045,7 @@ install_tools_helper() {
info "Install static ${tool_binary}"
mkdir -p "${destdir}/opt/kata/bin/"
[ ${tool} = "csi-kata-directvolume" ] && tool_binary="csi-kata-directvolume"
install -D --mode ${binary_permissions} ${binary} "${destdir}/opt/kata/bin/${tool_binary}"
}
@@ -1054,6 +1057,10 @@ install_genpolicy() {
install_tools_helper "genpolicy"
}
install_csi_kata_directvolume() {
install_tools_helper "csi-kata-directvolume"
}
install_kata_ctl() {
install_tools_helper "kata-ctl"
}
@@ -1131,6 +1138,8 @@ handle_build() {
cloud-hypervisor-glibc) install_clh_glibc ;;
csi-kata-directvolume) install_csi_kata_directvolume ;;
firecracker) install_firecracker ;;
genpolicy) install_genpolicy ;;
@@ -1350,6 +1359,7 @@ main() {
agent-ctl
cloud-hypervisor
coco-guest-components
csi-kata-directvolume
firecracker
genpolicy
kata-ctl

View File

@@ -0,0 +1 @@
install_libseccomp.sh

View File

@@ -10,9 +10,12 @@ COPY install_libseccomp.sh /usr/bin/install_libseccomp.sh
ENV DEBIAN_FRONTEND=noninteractive
ENV GO_HOME="/opt"
ENV GOCACHE="${GO_HOME}/.cache"
ENV GOMODCACHE="${GO_HOME}/.modcache"
ENV RUSTUP_HOME="/opt/rustup"
ENV CARGO_HOME="/opt/cargo"
ENV PATH="/opt/cargo/bin/:${PATH}"
ENV PATH="/opt/cargo/bin/:/opt/go/bin:${PATH}"
ENV OPT_LIB="/opt/lib"
ENV LIBSECCOMP_LINK_TYPE=static
@@ -44,6 +47,11 @@ RUN apt-get update && \
# Tools only build for x86_64
RUN rustup target add x86_64-unknown-linux-musl
RUN kernelname=$(uname -s | tr '[:upper:]' '[:lower:]'); \
curl -OL "https://storage.googleapis.com/golang/go${GO_TOOLCHAIN}.${kernelname}-amd64.tar.gz" && \
tar -C "${GO_HOME}" -xzf "go${GO_TOOLCHAIN}.${kernelname}-amd64.tar.gz" && \
rm "go${GO_TOOLCHAIN}.${kernelname}-amd64.tar.gz"
# cmake looks for musl binutils
# For setting CMAKE_AR, find_program searches for musl-ar.
# Symlink to system ar.

View File

@@ -20,6 +20,7 @@ container_image="${TOOLS_CONTAINER_BUILDER:-$(get_tools_image_name)}"
docker pull ${container_image} || \
(docker $BUILDX build $PLATFORM \
--build-arg GO_TOOLCHAIN="$(get_from_kata_deps ".languages.golang.meta.newest-version")" \
--build-arg RUST_TOOLCHAIN="$(get_from_kata_deps ".languages.rust.meta.newest-version")" \
-t "${container_image}" "${script_dir}" && \
# No-op unless PUSH_TO_REGISTRY is exported as "yes"