dockerkubernetesgoogle-cloud-platformgoogle-kubernetes-enginegoogle-artifact-registry

CrashLoopBackOff when pulling image form Artifact-Registry inside GKE Deployment


Hello and thank you for your assistance!

I am experiencing some unusual behavior within my GKE cluster (1.26.5-gke.1400) when attempting to pull images from the artifact registry. Both services are located within the same GCP project. My GKE cluster is utilizing the default compute service account, which has been granted the Artifact Registry Reader permission.

My objective is to deploy a simple nginx application that loads an index.html file from a Docker Image. However, with the configuration described, I am encountering the following error in the logs:

CrashLoopBackOff - exec /docker-entrypoint.sh: exec format error

# deployment.yml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: hochzeitsautoschwerin
  namespace: hochzeitsautoschwerin
spec:
  selector:
    matchLabels:
      app: hochzeitsautoschwerin
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: hochzeitsautoschwerin
    spec:
      containers:
      - image: europe-west4-docker.pkg.dev/jenkins-389117/test-images/test:1.0.0
        name: testdeployment
        ports:
        - containerPort: 8080
          name: web
        resources:
          limits:
            cpu: "0.2" 
            memory: "256Mi" 
          requests:
            cpu: "0.1"
            memory: "100Mi"

My dockerfile looks like this:

FROM --platform=linux/amd64 nginx:latest

COPY src/index.html /usr/share/nginx/html/index.html
COPY docker/docker-entrypoint.sh /docker-entrypoint.sh

RUN chmod +x /docker-entrypoint.sh
RUN echo "[i]  Starting docker-entrypoint.sh"

CMD ["/docker-entrypoint.sh"]

The docker-entrypoint.sh is defined like this:

#!/bin/sh

# Start NGINX
exec nginx -g 'daemon off;'

echo "[i] nginx started"

The artifact is also stored correctly. shows the stored artifact image


Solution

  • The error CrashLoopBackOff means that there's an error happening that prevents a Pod from starting properly. So the image is found and stored properly but it doesn't run correctly.

    The error that prevents it to run is:

    CrashLoopBackOff - exec /docker-entrypoint.sh: exec format error

    This usually happens because the architecture of the platform where you run it is different to the architecture where you built the Docker image.

    To do that you should add to your Dockerfile the platform, such as:

    FROM --platform=linux/amd64 nginx:latest