kubernetes-engine-samples icon indicating copy to clipboard operation
kubernetes-engine-samples copied to clipboard

hello-app example fails on Apple M1 machine

Open ericdrosas87 opened this issue 3 years ago • 2 comments

The image golang:1.8-alpine did not build on my M1 Macbook. There was an error in the terminal about Docker being unable to find the metadata for this image.

Instead, I had to use: golang:alpine3.13

This led me to making the following changes to the Dockerfile:

#FROM golang:1.8-alpine
FROM golang:alpine3.13
ADD . /go/src/hello-app
WORKDIR /go/src/hello-app
RUN go mod init
RUN go mod tidy
RUN go install hello-app

FROM alpine:latest
COPY --from=0 /go/bin/hello-app .
ENV PORT 8080
CMD ["./hello-app"]

This built fine, but when it came time to deploy this image to the GKE cluster (which succeeded) the pods were stuck in a status of "CrashLoopBackOff".

The only line in the pod log was:

standard_init_linux.go:211: exec user process caused "exec format error"

...which I learned through some Googling happens when you build on one architecture and deploy to another.

I had to build using buildx in order to get the deployment up and running successfully:

docker buildx build --platform linux/amd64 -t <image name> .

I suggest modifying the associated tutorials to offer this alternative route to deployment for M1 machines.

ericdrosas87 avatar May 06 '21 21:05 ericdrosas87

Moving this to a P3 given ongoing discussions for docker build instructions for M1 machines, across GCP samples and docs.

Our guidance through the end of 2021 is that this sample repo only supports AMD machines.

askmeegs avatar Nov 17 '21 16:11 askmeegs

cooling off for OSLO and providing an update, this sample repo still only supports AMD machines

xtineskim avatar May 26 '22 19:05 xtineskim