<p>I have simple <code>Dockerfile</code> for Angular 10 app.</p>
<pre><code>FROM node:12.2.0-alpine
WORKDIR /usr/src/app/e-wallet-web

COPY package*.json ./

RUN npm install -g @angular/cli@10.0.1 @angular-devkit/build-angular @angular/material@10.0.1 @angular/flex-layout@10.0.0-beta.32 &amp;&amp; npm install

EXPOSE 4200

CMD ng serve --host 0.0.0.0
</code></pre>
<p>Now I created <code>docker-compose</code> to deploy with other app like backend, database.</p>
<p><a href="https://i.stack.imgur.com/Ueljd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ueljd.png" alt="enter image description here" /></a></p>
<p>When I run <code>docker-compose up</code> command, it is working fine. Now I want to deploy on <code>kubernetes</code>, for that I created a <code>deployment.yml</code> file like this.</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: walletaweb-deployment
  namespace: ewallet
spec:
  selector:
    matchLabels:
      app: walletaweb-pod
  template:
    metadata:
      labels:
        app: walletaweb-pod
    spec:
      containers:
      - name: ewalletweb
        image: ewalletweb:latest
        imagePullPolicy: IfNotPresent
        resources:
          limits:
            memory: &quot;128Mi&quot;
            cpu: &quot;500m&quot;
        ports:
        - containerPort: 80
</code></pre>
<p>It is not working. When I see the logs of that pod, it is showing error <code>The serve command requires to be run in an Angular project, but a project definition could not be found.</code></p>
<p><a href="https://i.stack.imgur.com/QzVaa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QzVaa.png" alt="enter image description here" /></a></p>
<p>Pod description:</p>
<pre><code>PS &gt; kubectl describe -n ewallet pod walletaweb-deployment-6789b56ccf-prmbk
Name:         walletaweb-deployment-6789b56ccf-prmbk
Namespace:    ewallet
Priority:     0
Node:         docker-desktop/192.168.65.3
Start Time:   Tue, 21 Jul 2020 12:58:42 +0600
Labels:       app=walletaweb-pod
              pod-template-hash=6789b56ccf
Annotations:  &lt;none&gt;
Status:       Running
IP:           10.1.0.58
IPs:
  IP:           10.1.0.58
Controlled By:  ReplicaSet/walletaweb-deployment-6789b56ccf
Containers:
  ewalletweb:
    Container ID:   docker://fa1daff061031490043d83d322c11da7ba308a333deb61c6fdbee4fa21e96e26
    Image:          ewalletweb:latest
    Image ID:       docker://sha256:21bf5c443bd740aaab1fd66ce3342d8093648f884a91b1ccf6b4d76d20d11304
    Port:           80/TCP
    Host Port:      0/TCP
    State:          Waiting
      Reason:       CrashLoopBackOff
    Last State:     Terminated
      Reason:       Error
      Exit Code:    1
      Started:      Tue, 21 Jul 2020 13:20:10 +0600
      Finished:     Tue, 21 Jul 2020 13:20:11 +0600
    Ready:          False
    Restart Count:  9
    Limits:
      cpu:     500m
      memory:  128Mi
    Requests:
      cpu:        500m
      memory:     128Mi
    Environment:  &lt;none&gt;
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-fz7rk (ro)
Conditions:
  Type              Status
  Initialized       True
  Ready             False
  ContainersReady   False
  PodScheduled      True
Volumes:
  default-token-fz7rk:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-fz7rk
    Optional:    false
QoS Class:       Guaranteed
Node-Selectors:  &lt;none&gt;
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                 node.kubernetes.io/unreachable:NoExecute for 300s
Events:
  Type     Reason     Age                 From                     Message
  ----     ------     ----                ----                     -------
  Normal   Scheduled  &lt;unknown&gt;           default-scheduler        Successfully assigned ewallet/walletaweb-deployment-6789b56ccf-prmbk to docker-desktop
  Normal   Pulled     20m (x5 over 21m)   kubelet, docker-desktop  Container image &quot;ewalletweb:latest&quot; already present on machine
  Normal   Created    20m (x5 over 21m)   kubelet, docker-desktop  Created container ewalletweb
  Normal   Started    20m (x5 over 21m)   kubelet, docker-desktop  Started container ewalletweb
  Warning  BackOff    96s (x92 over 21m)  kubelet, docker-desktop  Back-off restarting failed container
</code></pre>

Moshi
<p>Your Dockerfile doesn't <code>COPY</code> the Angular application into the image, so it's not there when <code>ng serve</code> runs.  You need to add to your Dockerfile, after the <code>RUN npm install</code> line, something along the lines of</p>
<pre><code>COPY . .
</code></pre>
<p>Make sure you also have a <code>.dockerignore</code> file that causes the host's <code>node_modules</code> directory to be excluded from the build.</p>
<p>It looks like your <code>docker-compose.yml</code> file injects your host's code into the container, and then tells Docker to use some (potentially old) version of the <code>node_modules</code> tree to overwrite what the Dockerfile does.  You will get the same error if you delete the <code>volumes:</code> block there.  (That's generally good practice: if you're replacing all of the code and the entire app directory in the container, what you're running in Compose is fundamentally different from what you're trying to run in Kubernetes.)</p>
<p>You approximately can't replicate this developer-oriented setup in Kubernetes.  (In principle you can, but only on a single-node cluster like Minikube, and the YAML to do it is as long as the deployment spec you currently have.)  Images must be self-contained and include all of their code and dependencies.</p>
