Search code examples
dockerkubernetesdeploymentamazon-eksamazon-ecr

Error with only ECR image Back-off restarting failed container


I'm new with k8s and I've deployed a simple nginx deployment using eks and ecr. The problem only present when I'm using ecr image, it's not happens with nginx public image from docker hub. Here is my deployment file.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      imagePullSecrets:
        - name: *-ecr-registry
      containers:
        - name: nginx
          # image: nginx:latest
          image: *.dkr.ecr.*.amazonaws.com/nginx:dev

Here is output of a pod.

Events:
  Type     Reason     Age                From               Message
  ----     ------     ----               ----               -------
  Normal   Scheduled  12s                default-scheduler  Successfully assigned *
  Normal   Pulled     10s (x2 over 12s)  kubelet            Container image * already present on machine
  Normal   Created    10s (x2 over 12s)  kubelet            Created container nginx
  Normal   Started    10s (x2 over 11s)  kubelet            Started container nginx
  Warning  BackOff    8s (x2 over 9s)    kubelet            Back-off restarting failed container

Here is result log of the pod

exec /docker-entrypoint.sh: exec format error

I also ran the ecr image with docker in my local machine without any error. Can someone give me some hints, how can I overcome this issue, thanks in advance.


Solution

  • After hours of trying many ways, I realize that I'm using base-image keymetrics/pm2:18-alpine only supports amd64 kernel. Even I tried to rebuild my image in arm64, that doesn't not work in my work nodes with arm64 kernel type. So I see 2 ways to overcome this issue is:

    • recreate my eks cluster using amd64 worker nodes.
    • Or switch to other base-image like node:18.14-alpine that supports both arm64 and amd64 kernel.