错误 - 在创建服务时,重新启动失败的容器-问答-阿里云开发者社区-阿里云

开发者社区> 问答> 正文

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

k8s小能手 2019-01-11 13:57:56 1773

正如标题中所述,我遇到了错误

在创建服务时,重新启动失败的容器

我已经看到Stack Overflow上的问题,但我仍然不确定如何解决它。

这是我的部署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

而服务部署文件是:

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
这是我的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" ]

创建失败错误 错误启动失败 容器服务创建 容器服务创建的 创建错误
分享到
取消 提交回答
全部回答(1)
  • k8s小能手
    2019-07-17 23:25:18

    我尝试在本地运行您的部署,这就是显示的日志:

    kubectl log book-api-8d98bf6d5-zbv4q

    Usage: npm

    where 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 -h quick help on
    npm -l display full usage info
    npm help search for help on
    npm help npm involved overview

    Specify configs in the ini-formatted file:

    /root/.npmrc

    or on the command line via: npm --key value
    Config info can be viewed via: npm help config

    npm@6.5.0-next.0 /usr/local/lib/node_modules/npm
    默认情况下,使用newmaster / kubecourse-books:v1似乎没有命令运行

    我想如果你想运行默认的npm命令,你可以运行以下部署配置(注意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
    0 0
云原生
使用钉钉扫一扫加入圈子
+ 订阅

云原生时代,是开发者最好的时代

相似问题
最新问题