简体   繁体   English

将 Node/mongodb 应用程序部署到 GKE 并且它因 crashloopbackoff 不断失败

[英]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 availabilitycrashloopbackoff 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.

相关问题 使用Heroku(始终为本地端口)部署Node.js(+ MongoDB)应用程序 - Deploying a Node.js(+MongoDB) app with Heroku, always Local Port 在数字海洋上使用mokodb与dokku部署node.js应用程序 - deploying node.js app with mongodb with dokku on digital ocean GitLab 在部署 dockerized node.js 应用程序时不断加载并最终失败 - GitLab keeps loading and finally fails when deploying a dockerized node.js app MongoDB 使用 NodeJS 更新 JsonValidator 不断失败 - MongoDB update JsonValidator with NodeJS keeps failing 在 IIS 中部署 Node App - Deploying Node App in IIS MongoDB findOne在node.js应用程序中第二次失败...连接到以下错误:mongodb:// - MongoDB findOne failing SECOND TIME in node.js app… ERROR connecting to: mongodb:// 部署 NODE.JS + MONGODB(CRUD APP)时在 HEROKU 上连接 ECONNREFUSED 127.0.0.1:3000 - connect ECONNREFUSED 127.0.0.1:3000 on HEROKU when deploying NODE.JS + MONGODB (CRUD APP) 在Elastic Beanstalk上使用mongoDB部署Node.Js应用程序时出现错误 - I'm getting an error while deploying Node.Js app with mongoDB on Elastic Beanstalk Heroku Node 应用程序不断崩溃 - Heroku Node app keeps crashing 将节点应用程序部署到heroku时出错 - Error deploying node app to heroku
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM