Skip to content

Commit 72ec118

Browse files
committed
feat(velero): build the KubeVirt plugin image for amd64 and arm64
Upstream publishes quay.io/kubevirt/kubevirt-velero-plugin for amd64 only, so on an arm64 cluster the velero server never starts: its plugin init container fails with "exec format error". Rebuild the plugin in-tree from the v0.9.0 release tag, cross-compiled on the build platform, into an image that behaves like upstream's: it copies the plugin binary into the plugins volume at /target. The image target stamps the built reference by digest into values.yaml, and the package joins the root build list so every build path refreshes that pin. Until the first stamp is committed the upstream reference stays in place, which the chart test accepts alongside the digest-pinned in-tree one. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <[email protected]>
1 parent 084ac47 commit 72ec118

4 files changed

Lines changed: 42 additions & 2 deletions

File tree

‎Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ build: build-deps
3737
make -C packages/system/securitygroup-controller image
3838
make -C packages/system/grafana-operator image
3939
make -C packages/system/redis-operator image
40+
make -C packages/system/velero image
4041
make -C packages/system/opensearch-operator image
4142
make -C packages/core/testing image
4243
make -C packages/core/talos image

‎packages/system/velero/Makefile‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,23 @@
1+
KUBEVIRT_VELERO_PLUGIN_TAG=$(shell grep -F 'ARG VERSION=' images/kubevirt-velero-plugin/Dockerfile | cut -f2 -d=)
12
export NAME=velero
23
export NAMESPACE=cozy-$(NAME)
34

5+
include ../../../hack/common-envs.mk
46
include ../../../hack/package.mk
57

8+
image:
9+
docker buildx build images/kubevirt-velero-plugin \
10+
$(call image-tags,kubevirt-velero-plugin,$(KUBEVIRT_VELERO_PLUGIN_TAG)) \
11+
$(call cache-args,kubevirt-velero-plugin) \
12+
--metadata-file images/kubevirt-velero-plugin.json \
13+
$(BUILDX_ARGS)
14+
# sed rather than yq -i: yq re-indents the initContainers list and drops
15+
# blank lines elsewhere in the file, so every stamp would reformat it.
16+
IMAGE="$(REGISTRY)/kubevirt-velero-plugin:$(IMAGE_TAG)@$$(yq e '."containerimage.digest"' images/kubevirt-velero-plugin.json -o json -r)" && \
17+
sed -i "s|image: [^ ]*/kubevirt-velero-plugin:[^ ]*$$|image: $$IMAGE|" values.yaml && \
18+
grep -qF "image: $$IMAGE" values.yaml
19+
rm -f images/kubevirt-velero-plugin.json
20+
621
test:
722
helm unittest .
823

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Upstream publishes this image for amd64 only, so it is rebuilt here from the
2+
# release tag for every platform the velero server runs on.
3+
FROM --platform=$BUILDPLATFORM golang:1.27@sha256:3680233e3204827fbdc66088528ae6d4b3d034f51d03a99d454f6de034888244 AS builder
4+
5+
ARG VERSION=v0.9.0
6+
ARG TARGETOS
7+
ARG TARGETARCH
8+
9+
WORKDIR /workspace
10+
11+
RUN curl -sSfL https://github.com/kubevirt/kubevirt-velero-plugin/archive/refs/tags/${VERSION}.tar.gz | tar -xzf- --strip=1
12+
13+
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH CGO_ENABLED=0 go build -installsuffix static -o kubevirt-velero-plugin .
14+
15+
# The velero server runs this as an init container whose entrypoint copies the
16+
# plugin into the plugins volume mounted at /target, so the image needs a shell
17+
# and cp, as upstream's alpine base provides.
18+
FROM alpine:3.24@sha256:294b683cb724975bec92580e1e685676bd4b50bda910ddb8c51d4cabeaec77e6
19+
COPY --from=builder /workspace/kubevirt-velero-plugin /plugins/
20+
USER nobody:nogroup
21+
ENTRYPOINT ["/bin/sh", "-c", "cp /plugins/* /target/."]

‎packages/system/velero/tests/velero_test.yaml‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@ tests:
2222
- equal:
2323
path: spec.template.spec.initContainers[0].image
2424
value: velero/velero-plugin-for-aws:v1.14.1
25-
- equal:
25+
# The build stamps the in-tree multi-arch image by digest and release
26+
# preparation commits it, so the tag half is not stable. Until the first
27+
# stamp lands the upstream amd64-only ref is still committed.
28+
- matchRegex:
2629
path: spec.template.spec.initContainers[1].image
27-
value: quay.io/kubevirt/kubevirt-velero-plugin:v0.9.0
30+
pattern: '^(ghcr\.io/cozystack/cozystack/kubevirt-velero-plugin:[^@]+@sha256:[0-9a-f]{64}|quay\.io/kubevirt/kubevirt-velero-plugin:v0\.9\.0)$'
2831

2932
# Cozystack disables the upgrade-crds Job (upgradeCRDs: false): CRD lifecycle
3033
# is owned by the generated HelmRelease (upgradeCRDs: CreateReplace on the

0 commit comments

Comments
 (0)