Kuberenetes: receive CrashLoopBackOff

4/11/2018

I can successfully run the following image on a local container.

Dockerfile:

FROM ubuntu:latest

RUN apt-get update
RUN apt-get -qq update
RUN apt-get install -y nodejs npm
# TODO could uninstall some build dependencies

# debian installs `node` as `nodejs`
RUN update-alternatives --install /usr/bin/node node /usr/bin/nodejs 10

COPY package.json package.json

RUN npm install

COPY . .

CMD ["npm", "start"]

The current folder holds a simple "hello world" node-express app, and I can curl it to localhost:3000.

The depolyment.yml:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: node-deployment
  labels:
    app: node-app
spec:
  replicas: 2
  selector:
    matchLabels:
      app: node-app
  template:
    metadata:
      labels:
        app: node-app
    spec:
      containers:
      - name: node-app
        image: my-repo/ubuntu-node:firsttry 
        ports:
        - containerPort: 3000

and the event (kubectl describe pod):

Warning  BackOff                40s (x20 over 5m)  kubelet, minikube  Back-off restarting failed container

Any suggestions about how to solve the issue?

-- Chen
kubernetes
minikube

1 Answer

4/11/2018

Well, The pod was created and then crashed over and over again. I discover that by running:

kubctl logs node-deployment-57568f8f75-c2brt

And it was a nodemon problem:

[nodemon] watching: *.*
[nodemon] starting `node app.js`
Example app listening on port 3000!
[nodemon] Internal watch failed: watch /usr/lib/x86_64-linux-gnu/libanl.a ENOSPC

For now I just changed the CMD in the Dockerfile to:

CMD ["node", "app.js"]

And now the pods are running.

-- Chen
Source: StackOverflow