<p>I deployed my nodejs/typeScript container alongside mongodb image on GKE. But the nodejs app deployment keeps failing, and I know because I can't hit the server with the external IP address and port. When I inspect the deployment on GCP console, I see that it fails with error: <code>Does not have minimum availability</code> and <code>crashloopbackoff</code>.
From the logs I could also see that the app fails to connect to the database I deployed alongside it, so it appears it can't also find the MongoDB service, could it be why it says <code>crashloopbackoff</code>?</p>
<p>Here are the yaml files for the components I deployed:</p>
<p>MongoDB pod</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: mongodb
  labels:
    app: mongodb
spec:
  containers:
    - name: mongodb
      image: mongo
      ports:
        - containerPort: 27017
          name: mongodb-port

</code></pre>
<p>MongoDB service</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: mongodb # Same service name I used in my db url
spec:
  ports:
    - port: 27017
      protocol: TCP
  selector:
    app: mongodb
  type: ClusterIP
</code></pre>
<p>Back-end pod’s service</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: journal-api-service
spec:
  ports:
    - port: 8080
      protocol: TCP
      targetPort: http-port
  selector:
    app: journal-api
    tier: backend
  type: LoadBalancer
</code></pre>
<p>Back-end deployment</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: journal-api-deployment
spec:
  selector:
    matchLabels:
      app: journal-api
      tier: backend
  replicas: 1
  template:
    metadata:
      labels:
        app: journal-api
        tier: backend
    spec:
      containers:
        - image: shulaa/journal-api:v1
          name: journal-api
          ports:
            - containerPort: 8080
              name: http-port
</code></pre>
<p>and I created them in the exact order I provided it here.
The mongo and nodejs app containers run fine when I run them locally.</p>

Aso Amarachi
<p>That's due to the</p>
<pre><code>Does not have minimum availability
</code></pre>
<p>your container is not coming up or running due to a resource outage. No resources into the cluster to run the container.</p>
<p>Now you should add New node so K8s can allocate some resources to container, or delete running pods.</p>
<p>You check Node status using the</p>
<pre><code>kubectl get nodes 
</code></pre>
<p>check resource of Nodes</p>
<pre><code>kubectl top nodes  
</code></pre>
<p>if your nodes as resources left there could be a chance no resource left GCP side in zone or so</p>
<blockquote>
<p>Wait. Google Cloud does not have enough resource available in the
Region/Zone that you are trying to launch into. In some cases, this
took an hour to an entire day.</p>
<p>Select a different Region/Zone.</p>
</blockquote>
