[英]Deploying Node/mongodb app to GKE and it keeps failing with crashloopbackoff
I deployed my nodejs/typeScript container alongside mongodb image on GKE.我在 GKE 上部署了我的 nodejs/typeScript 容器和 mongodb 镜像。 But the nodejs app deployment keeps failing, and I know because I can't hit the server with the external IP address and port.但是 nodejs 应用程序部署一直失败,我知道是因为我无法使用外部 IP 地址和端口访问服务器。 When I inspect the deployment on GCP console, I see that it fails with error: Does not have minimum availability
and crashloopbackoff
.当我在 GCP 控制台上检查部署时,我发现它失败并显示错误: Does not have minimum availability
和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
?从日志中,我还可以看到该应用程序无法连接到我与它一起部署的数据库,因此它似乎也找不到 MongoDB 服务,这可能是它显示crashloopbackoff
吗?
Here are the yaml files for the components I deployed:以下是我部署的组件的 yaml 文件:
MongoDB pod MongoDB 吊舱
apiVersion: v1
kind: Pod
metadata:
name: mongodb
labels:
app: mongodb
spec:
containers:
- name: mongodb
image: mongo
ports:
- containerPort: 27017
name: mongodb-port
MongoDB service MongoDB服务
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后端 pod 的服务
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.当我在本地运行 mongo 和 nodejs 应用程序容器时,它们运行良好。
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.现在您应该添加新节点,以便 K8s 可以为容器分配一些资源,或者删除正在运行的 Pod。
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如果您的节点作为资源剩余,则可能没有资源在区域左右的 GCP 侧留下
Wait.等待。 Google Cloud does not have enough resource available in the Region/Zone that you are trying to launch into. GCP 在您尝试启动的区域/地区中没有足够的可用资源。 In some cases, this took an hour to an entire day.在某些情况下,这需要一个小时到一整天。
Select a different Region/Zone.选择不同的区域/区域。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.