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:
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:
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.
Repo is over here: https://github.com/codemasternode/BookService.Kubecourse.git
node.js docker kubernetes
add a comment |
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:
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:
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.
Repo is over here: https://github.com/codemasternode/BookService.Kubecourse.git
node.js docker kubernetes
add a comment |
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:
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:
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.
Repo is over here: https://github.com/codemasternode/BookService.Kubecourse.git
node.js docker kubernetes
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:
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:
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.
Repo is over here: https://github.com/codemasternode/BookService.Kubecourse.git
node.js docker kubernetes
node.js docker kubernetes
edited Jan 2 at 17:11
newmaster
asked Jan 1 at 23:04
newmasternewmaster
53
53
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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
I guess if you want to run the default npm command, you could run the following deploy config (note the command value):
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
Really??, there is npm start statement in my Dockerfile, isn't enough?
– newmaster
Jan 2 at 8:03
Can you please share the content of your Dockerfile, you used for building the docker image, or command`s output of "docker image inspect newmaster/kubecourse-books:v1"
– Nepomucen
Jan 2 at 10:38
I edited my post, add Dockerfile and of course add github repo
– newmaster
Jan 2 at 19:18
Did you try with CMD [ "npm", "run", "serve" ] in the Dockerfile?
– Quentin Revel
Jan 2 at 19:33
1
I mean in Dockerfile was CMD with npm serve instead of npm run serve.
– newmaster
Jan 3 at 7:38
|
show 1 more comment
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53999617%2ferror-back-off-restarting-failed-container-while-creating-a-service%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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
I guess if you want to run the default npm command, you could run the following deploy config (note the command value):
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
Really??, there is npm start statement in my Dockerfile, isn't enough?
– newmaster
Jan 2 at 8:03
Can you please share the content of your Dockerfile, you used for building the docker image, or command`s output of "docker image inspect newmaster/kubecourse-books:v1"
– Nepomucen
Jan 2 at 10:38
I edited my post, add Dockerfile and of course add github repo
– newmaster
Jan 2 at 19:18
Did you try with CMD [ "npm", "run", "serve" ] in the Dockerfile?
– Quentin Revel
Jan 2 at 19:33
1
I mean in Dockerfile was CMD with npm serve instead of npm run serve.
– newmaster
Jan 3 at 7:38
|
show 1 more comment
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
I guess if you want to run the default npm command, you could run the following deploy config (note the command value):
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
Really??, there is npm start statement in my Dockerfile, isn't enough?
– newmaster
Jan 2 at 8:03
Can you please share the content of your Dockerfile, you used for building the docker image, or command`s output of "docker image inspect newmaster/kubecourse-books:v1"
– Nepomucen
Jan 2 at 10:38
I edited my post, add Dockerfile and of course add github repo
– newmaster
Jan 2 at 19:18
Did you try with CMD [ "npm", "run", "serve" ] in the Dockerfile?
– Quentin Revel
Jan 2 at 19:33
1
I mean in Dockerfile was CMD with npm serve instead of npm run serve.
– newmaster
Jan 3 at 7:38
|
show 1 more comment
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
I guess if you want to run the default npm command, you could run the following deploy config (note the command value):
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
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
I guess if you want to run the default npm command, you could run the following deploy config (note the command value):
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
answered Jan 2 at 0:06
Quentin RevelQuentin Revel
76038
76038
Really??, there is npm start statement in my Dockerfile, isn't enough?
– newmaster
Jan 2 at 8:03
Can you please share the content of your Dockerfile, you used for building the docker image, or command`s output of "docker image inspect newmaster/kubecourse-books:v1"
– Nepomucen
Jan 2 at 10:38
I edited my post, add Dockerfile and of course add github repo
– newmaster
Jan 2 at 19:18
Did you try with CMD [ "npm", "run", "serve" ] in the Dockerfile?
– Quentin Revel
Jan 2 at 19:33
1
I mean in Dockerfile was CMD with npm serve instead of npm run serve.
– newmaster
Jan 3 at 7:38
|
show 1 more comment
Really??, there is npm start statement in my Dockerfile, isn't enough?
– newmaster
Jan 2 at 8:03
Can you please share the content of your Dockerfile, you used for building the docker image, or command`s output of "docker image inspect newmaster/kubecourse-books:v1"
– Nepomucen
Jan 2 at 10:38
I edited my post, add Dockerfile and of course add github repo
– newmaster
Jan 2 at 19:18
Did you try with CMD [ "npm", "run", "serve" ] in the Dockerfile?
– Quentin Revel
Jan 2 at 19:33
1
I mean in Dockerfile was CMD with npm serve instead of npm run serve.
– newmaster
Jan 3 at 7:38
Really??, there is npm start statement in my Dockerfile, isn't enough?
– newmaster
Jan 2 at 8:03
Really??, there is npm start statement in my Dockerfile, isn't enough?
– newmaster
Jan 2 at 8:03
Can you please share the content of your Dockerfile, you used for building the docker image, or command`s output of "docker image inspect newmaster/kubecourse-books:v1"
– Nepomucen
Jan 2 at 10:38
Can you please share the content of your Dockerfile, you used for building the docker image, or command`s output of "docker image inspect newmaster/kubecourse-books:v1"
– Nepomucen
Jan 2 at 10:38
I edited my post, add Dockerfile and of course add github repo
– newmaster
Jan 2 at 19:18
I edited my post, add Dockerfile and of course add github repo
– newmaster
Jan 2 at 19:18
Did you try with CMD [ "npm", "run", "serve" ] in the Dockerfile?
– Quentin Revel
Jan 2 at 19:33
Did you try with CMD [ "npm", "run", "serve" ] in the Dockerfile?
– Quentin Revel
Jan 2 at 19:33
1
1
I mean in Dockerfile was CMD with npm serve instead of npm run serve.
– newmaster
Jan 3 at 7:38
I mean in Dockerfile was CMD with npm serve instead of npm run serve.
– newmaster
Jan 3 at 7:38
|
show 1 more comment
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53999617%2ferror-back-off-restarting-failed-container-while-creating-a-service%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown