Pod errors: CrashLoopBackOff (GKE)

11/2/2019

enter image description here

Hi. First of all, I know that it can be some kind of duplication. But answers which I've fouds doesn't help me. Here is my case.

I want to create a deployment of my docker image by using GCP (GKE). I create it by using gke ui ( in workloads menu) . My image was created by docker file which you can see here :

FROM keymetrics/pm2:latest-alpine

COPY dist dist/
COPY package.json .
COPY pm2.json .

RUN npm install --production

RUN ls -al -R

CMD [ "pm2", "start", "pm2.json", "-p", "3000:80" ]

I've started this image locally and it was working correctly. Here you can see it :

sudo docker run booknotes-app

[PM2] Spawning PM2 daemon with pm2_home=/root/.pm2
[PM2] PM2 Successfully daemonized
[PM2][WARN] Applications booknotes-app not running, starting...
[PM2] App [booknotes-app] launched (1 instances)
┌───────────────┬────┬─────────┬──────┬─────┬────────┬─────────┬────────┬─────┬───────────┬──────┬──────────┐
│ App name      │ id │ version │ mode │ pid │ status │ restart │ uptime │ cpu │ mem       │ user │ watching │
├───────────────┼────┼─────────┼──────┼─────┼────────┼─────────┼────────┼─────┼───────────┼──────┼──────────┤
│ booknotes-app │ 0  │ N/A     │ fork │ 24  │ online │ 0       │ 0s     │ 0%  │ 22.9 MB   │ root │ disabled │
└───────────────┴────┴─────────┴──────┴─────┴────────┴─────────┴────────┴─────┴───────────┴──────┴──────────┘
 Use `pm2 show <id|name>` to get more details about an app

You can also see my pods list:

enter image description here

And also you can see logs of my crushed pod:

kubectl logs booknotes-back-end-7f6766868f-5c92l
[PM2] Spawning PM2 daemon with pm2_home=/root/.pm2
[PM2] PM2 Successfully daemonized
[PM2][WARN] Applications booknotes-app not running, starting...
[PM2] App [booknotes-app] launched (1 instances)
┌───────────────┬────┬─────────┬──────┬─────┬────────┬─────────┬────────┬─────┬──────────┬──────┬──────────┐
│ App name      │ id │ version │ mode │ pid │ status │ restart │ uptime │ cpu │ mem      │ user │ watching │
├───────────────┼────┼─────────┼──────┼─────┼────────┼─────────┼────────┼─────┼──────────┼──────┼──────────┤
│ booknotes-app │ 0  │ N/A     │ fork │ 23  │ online │ 0       │ 0s     │ 0%  │ 3.2 MB   │ root │ disabled │
└───────────────┴────┴─────────┴──────┴─────┴────────┴─────────┴────────┴─────┴──────────┴──────┴──────────┘
 Use `pm2 show <id|name>` to get more details about an app

As you can see it looks the same as it looks locally. I've also tried to use solving from this response:

I got Pod errors: CrashLoopBackOff from kubernetes

I've added tty: true, but it didn't help me a lot. If you need additional info, pls let me know

-- Andrey Radkevich
google-kubernetes-engine
kubernetes

1 Answer

11/2/2019
CMD [ "pm2", "start", "pm2.json", "-p", "3000:80" ] --> CMD [ "pm2-runtime", "start", "pm2.json"]

The problem was in this line.

-- Andrey Radkevich
Source: StackOverflow