[英]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.