Reputation: 33
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: Does not have minimum availability
and crashloopbackoff
.
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 crashloopbackoff
?
Here are the yaml files for the components I deployed:
MongoDB pod
apiVersion: v1
kind: Pod
metadata:
name: mongodb
labels:
app: mongodb
spec:
containers:
- name: mongodb
image: mongo
ports:
- containerPort: 27017
name: mongodb-port
MongoDB service
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
Back-end pod’s service
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
Back-end deployment
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
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.
Upvotes: 0
Views: 373
Reputation: 30120
That's due to the
Does not have minimum availability
your container is not coming up or running due to a resource outage. No resources into the cluster to run the container.
Now you should add New node so K8s can allocate some resources to container, or delete running pods.
You check Node status using the
kubectl get nodes
check resource of Nodes
kubectl top nodes
if your nodes as resources left there could be a chance no resource left GCP side in zone or so
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.
Select a different Region/Zone.
Upvotes: 1