<p>As stated in the title I am experiencing error </p>

<blockquote>
  <p>Back-off restarting failed container while creating a service</p>
</blockquote>

<p>I've seen questions on Stack Overflow but I am still not sure how to resolve it.</p>

<p>This is my <strong>deployment yaml file</strong>:</p>

<pre><code>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
</code></pre>

<p>while the <strong>service deployment file</strong> is:</p>

<pre><code>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
</code></pre>

<p>This is my Dockerfile:</p>

<pre><code>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" ]
</code></pre>

<p>I have no idea how to resolve this issue, I am newbie in the Kubernetes and DevOps world.
Repo is over here: <a href="https://github.com/codemasternode/BookService.Kubecourse.git" rel="nofollow noreferrer">https://github.com/codemasternode/BookService.Kubecourse.git</a></p>

Marcin Warzybok
<p>I tried to run your deployment locally and this is what the log shown:</p>

<pre><code>kubectl log book-api-8d98bf6d5-zbv4q

Usage: npm &lt;command&gt;

where &lt;command&gt; 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 &lt;command&gt; -h  quick help on &lt;command&gt;
npm -l            display full usage info
npm help &lt;term&gt;   search for help on &lt;term&gt;
npm help npm      involved overview

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

npm@6.5.0-next.0 /usr/local/lib/node_modules/npm
</code></pre>

<p>It seems no command is running by default with the newmaster/kubecourse-books:v1 </p>

<p>I guess if you want to run the default npm command, you could run the following deploy config (note the <code>command</code> value):</p>

<pre><code>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
</code></pre>
