2

I'm getting the subject error when deploying my application to Kubernetes on Google Cloud.

From digging through this post - standard_init_linux.go:211: exec user process caused "exec format error" - it seems like the problem may be caused by the fact I'm building on a Macbook M1.

The proposed solution was to build on another machine.

Does anyone know of an alternative solution to this? I'd rather not have to change my machine just to get around this problem.

Here are the logs output with kubectl logs

Events:
  Type     Reason     Age                From               Message
  ----     ------     ----               ----               -------
  Normal   Scheduled  45s                default-scheduler  Successfully assigned default/api-6dd8df46dd-gfpvh to gke-mysite-staging-general-pool-d0c2609f-ljd9
  Normal   Pulled     38s                kubelet            Successfully pulled image "gcr.io/mysite/mysite-api/staging" in 4.51688779s
  Normal   Pulled     36s                kubelet            Successfully pulled image "gcr.io/mysite/mysite-api/staging" in 187.266825ms
  Normal   Pulling    18s (x3 over 42s)  kubelet            Pulling image "gcr.io/mysite/mysite-api/staging"
  Normal   Created    18s (x3 over 37s)  kubelet            Created container api
  Normal   Started    18s (x3 over 36s)  kubelet            Started container api
  Normal   Pulled     18s                kubelet            Successfully pulled image "gcr.io/mysite/mysite-api/staging" in 194.129326ms
  Warning  BackOff    1s (x6 over 35s)   kubelet            Back-off restarting failed container

Dockerfile

FROM ruby:2.7.0

ARG environment

ENV RAILS_ENV $environment

RUN apt-get update -qq && \
  DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \
  build-essential \
  make \
  gcc \
  g++ \
  libxml2-dev \
  libxslt-dev \
  pkg-config \
  libcurl3-dev \
  libpq-dev \
  nodejs \
  cron \
  libgmp3-dev && \
  apt-get clean && \
  rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

RUN mkdir /home/app
WORKDIR /home/app
COPY ./Gemfile /home/app/Gemfile
COPY ./Gemfile.lock /home/app/Gemfile.lock
RUN bundle update --bundler
RUN bundle install
COPY ./ /home/app

EXPOSE 3000

# Start the main process.
CMD ["rails", "server", "-b", "0.0.0.0"]

Deployment is done with Helm:- helm upgrade mysite-api . -f values.yaml

replicaCount: 1

app_version: "0.1"

deployments:
  mysite_api:
    image: gcr.io/mysite/mysite-api/staging
    pullPolicy: Always
    name: api
    label: api
    replicas: 1
    port: 3000
    nodepool: general-pool
    command: '["bundle", "exec", "puma", "-C", "config/puma.rb"]'

services:
  - name: api
    label: api
    port_container: 3000
    port_service: 3000
    type: NodePort
    selector: app
    selector_value: api

autoscaling:
  - name: api
    label: api
    deployment: api
    enabled: true
    minReplicas: 1
    maxReplicas: 3
    targetCPUUtilizationPercentage: 80
    targetMemoryUtilizationPercentage: 80
s89_
  • 1,533
  • 3
  • 25
  • 40
  • Does the deployment contain any of `command`, `args`? If so, please add them. – anemyte Jun 01 '21 at 11:54
  • Added the deploy step. – s89_ Jun 01 '21 at 11:58
  • Which of the two you need to run the app: `CMD` from the Dockerfile or `command` from Helm? Because the two are blended together into something unreasonable to me. Furthermore `command` must be an array in your case (remove single quotes), that's the likely cause of the error message. – anemyte Jun 01 '21 at 12:12
  • It will be the command from Helm. `command` shouldn't be an array in this case - we have other deployments which are working fine with this format. I suspect the issue is that my machine architecture is arm64. I have tried to build with `docker buildx build --platform linux/amd64` following this tutorial - https://www.docker.com/blog/multi-arch-images/ - but it didn't resolve my issue. – s89_ Jun 01 '21 at 12:40
  • Probably there is a binary that is built specifically for ARM which doesn't work natively on linux. I'd reckon as a workaround you could try to: use cloud linux instance and connect to it using `docker machine` https://docs.docker.com/machine/ Or run build process remotely on the instance bringing there all required source files using git. – Dawid Kruk Jun 11 '21 at 11:24

0 Answers0