简体   繁体   English

错误-创建服务时退后重新启动失败的容器

[英]Error - Back-off restarting failed container while creating a service

As stated in the title I am experiencing error 如标题所述,我遇到错误

Back-off restarting failed container while creating a service 创建服务时退后重新启动失败的容器

I've seen questions on Stack Overflow but I am still not sure how to resolve it. 我已经看到有关堆栈溢出的问题,但是我仍然不确定如何解决它。

This is my deployment yaml file : 这是我的部署yaml文件

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: book-api
spec:
  replicas: 1
  revisionHistoryLimit: 10
  template:
    metadata:
      name: book-api
      labels:
        app: book-api
    spec:
      containers:
      - name: book-api
        image: newmaster/kubecourse-books:v1
        ports:
        - name: http
          containerPort: 3000

while the service deployment file is: 服务部署文件为:

kind: Service
apiVersion: v1
metadata:
  name: exampleservice
spec:
  selector:
    app: myapp
  ports:
    - protocol: "TCP"
      # Port accessible inside cluster
      port: 8081
      # Port to forward to inside the pod
      targetPort: 8080
      # Port accessible outside cluster
      nodePort: 30000
  type: LoadBalancer

This is my Dockerfile: 这是我的Dockerfile:

FROM node:alpine

# Create app directory
WORKDIR /src

# Install app dependencies
COPY package.json /src/
COPY package-lock.json /src/

RUN npm install

# Bundle app source
ADD . /src

RUN npm run build

EXPOSE 3000

CMD [ "npm", "run serve" ]

I have no idea how to resolve this issue, I am newbie in the Kubernetes and DevOps world. 我不知道如何解决这个问题,我是Kubernetes和DevOps世界的新手。 Repo is over here: https://github.com/codemasternode/BookService.Kubecourse.git 回购在这里: https : //github.com/codemasternode/BookService.Kubecourse.git

I tried to run your deployment locally and this is what the log shown: 我尝试在本地运行您的部署,这是显示的日志:

kubectl log book-api-8d98bf6d5-zbv4q

Usage: npm <command>

where <command> is one of:
    access, adduser, audit, bin, bugs, c, cache, ci, cit,
    clean-install, clean-install-test, completion, config,
    create, ddp, dedupe, deprecate, dist-tag, docs, doctor,
    edit, explore, get, help, help-search, hook, i, init,
    install, install-ci-test, install-test, it, link, list, ln,
    login, logout, ls, outdated, owner, pack, ping, prefix,
    profile, prune, publish, rb, rebuild, repo, restart, root,
    run, run-script, s, se, search, set, shrinkwrap, star,
    stars, start, stop, t, team, test, token, tst, un,
    uninstall, unpublish, unstar, up, update, v, version, view,
    whoami

npm <command> -h  quick help on <command>
npm -l            display full usage info
npm help <term>   search for help on <term>
npm help npm      involved overview

Specify configs in the ini-formatted file:
    /root/.npmrc
or on the command line via: npm <command> --key value
Config info can be viewed via: npm help config

npm@6.5.0-next.0 /usr/local/lib/node_modules/npm

It seems no command is running by default with the newmaster/kubecourse-books:v1 默认情况下,似乎没有命令在newmaster / kubecourse-books:v1中运行

I guess if you want to run the default npm command, you could run the following deploy config (note the command value): 我想如果您想运行默认的npm命令,则可以运行以下deploy config(注意command值):

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: book-api
spec:
  replicas: 1
  revisionHistoryLimit: 10
  template:
    metadata:
      name: book-api
      labels:
        app: book-api
    spec:
      containers:
      - name: book-api
        image: newmaster/kubecourse-books:v1
        command: ["npm", "start"]
        ports:
        - name: http
          containerPort: 3000

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用node.js和express进行openshift崩溃循环回退 - openshift crash loop back-off with node.js and express 在启用重试功能的情况下构建云功能时,如何实现增量退避? - When building a cloud function with retries enabled, how can I implement an incremental back-off? 如何在没有 http 端点的情况下保持 Kubernetes pod 运行? (防止后退) - How do I keep a Kubernetes pod running with no http endpoint? (prevent back-off) 错误:使用服务帐户创建 GCP 项目时用户未获得授权 - Error: User is not authorized while creating GCP project using service account Nodemon 未使用 docker 容器重新启动 - Nodemon is not restarting using docker container 在节点窗口中重新启动服务 - Restarting a service in node-windows 重新启动nodejs服务器时修复“connect()失败(111:连接被拒绝)”错误的任何好主意? - Any good ideas to fix “connect() failed (111: Connection refused)” error when restarting nodejs server? 我可以使用重新启动docker而不是重新启动容器中的应用程序吗? - Can I use restarting docker instead restarting app in container? 在Vue中创建项目时出错 - Error while creating a project in vue 电子“网络服务崩溃,正在重新启动服务。” - Electron "Network service crashed, restarting service."
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM