Kuberenetes:收到CrashLoopBackOff

时间:2018-04-11 10:51:25

标签: kubernetes minikube

我可以在本地容器上成功运行以下图像。

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"]

当前文件夹包含一个简单的" hello world" node-express app,我可以将它卷曲到localhost:3000

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

和事件(kubectl describe pod):

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

有关如何解决问题的任何建议?

1 个答案:

答案 0 :(得分:0)

嗯,创建了pod,然后一遍又一遍地崩溃。我发现通过运行:

kubctl logs node-deployment-57568f8f75-c2brt

这是一个nodemon问题:

[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

现在我刚刚将Dockerfile中的CMD更改为:

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

现在豆荚正在运行。