-
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Here are two modes to create builder in k8s With QEMU$ KUBECONFIG=${KUBECONFIG} \
docker buildx create \
--name=builder \
--platform=linux/amd64,linux/arm64 \
--driver=kubernetes \
--driver-opt=namespace=buildkit,qemu.install=true Known IssuesQEMU only work well for executing, but for compiling, it will be obviously slow and may be throw segmentation fault. In the mode, if still want to compile binaries in docker. Example for golang: FROM --platform=${BUILDPLATFORM} golang:1.6 as builder
ARG TARGETARCH
RUN GOARCH=${TARGETARCH} go build -o /bin/app-linux-${TARGETARCH} ./path/to/cmd/app
FROM scratch
ARG TARGETARCH
COPY --from=builder /bin/app-linux-${TARGETARCH} /bin/app With native nodes# create builder `builder` and add native x86_64 node
$ KUBECONFIG=${KUBECONFIG} \
docker buildx create \
--name=builder \
--platform=linux/amd64 \
--node=builder-amd64 \
--driver=kubernetes \
--driver-opt=namespace=buildkit,nodeselector="beta.kubernetes.io/arch=amd64"
# append node to same builder with native aarch64 node
$ KUBECONFIG=${KUBECONFIG} \
docker buildx create \
--name=builder --append \
--platform=linux/arm64 \
--node=builder-arm64 \
--driver=kubernetes \
--driver-opt=namespace=buildkit,nodeselector="beta.kubernetes.io/arch=arm64"
Known IssuesIn this mode, docker build for different arch on matched native host. However, it is totally native. TipsOnce Note:
However, For nodejs user. |
Beta Was this translation helpful? Give feedback.
Here are two modes to create builder in k8s
With QEMU
$ KUBECONFIG=${KUBECONFIG} \ docker buildx create \ --name=builder \ --platform=linux/amd64,linux/arm64 \ --driver=kubernetes \ --driver-opt=namespace=buildkit,qemu.install=true
Known Issues
QEMU only work well for executing, but for compiling, it will be obviously slow and may be throw segmentation fault.
In the mode, if still want to compile binaries in docker.
please use
FROM --platform=${BUILDPLATFORM}
to disable QEUM for compiling stage.Example for golang: