Node.js GKE部署反应JS应用程序崩溃回退
我已经为我的ReactJS应用程序构建了我的Docker映像。我在本地运行图像并对其进行了测试,效果良好 我正在使用Google Cloud Build,它会自动将我的容器映像放入gcr.io容器repo 然后,我尝试从驻留在gcr.io中的容器映像创建部署 但部署尚未成功完成。它给了我 吊舱错误:CrashLoopBackOff 没有最低可用性 这是我的Docker图像Node.js GKE部署反应JS应用程序崩溃回退,node.js,reactjs,docker,kubernetes,google-kubernetes-engine,Node.js,Reactjs,Docker,Kubernetes,Google Kubernetes Engine,我已经为我的ReactJS应用程序构建了我的Docker映像。我在本地运行图像并对其进行了测试,效果良好 我正在使用Google Cloud Build,它会自动将我的容器映像放入gcr.io容器repo 然后,我尝试从驻留在gcr.io中的容器映像创建部署 但部署尚未成功完成。它给了我 吊舱错误:CrashLoopBackOff 没有最低可用性 这是我的Docker图像 FROM node:latest RUN mkdir -p /usr/src/app WORKDIR /usr/src/ap
FROM node:latest
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY package.json .
RUN npm install
COPY . ./
EXPOSE 3000
CMD [ "npm", "start" ]
当我查看pod->container日志时,我看到我的应用程序一直在重新启动,没有任何错误日志
I 2020-04-27T15:07:57.505370601Z > react-scripts start
I 2020-04-27T15:07:57.505375001Z
I 2020-04-27T15:07:59.392880949Z [34mℹ[39m [90m「wds」[39m: Project is running at http://10.48.0.14/
I 2020-04-27T15:07:59.393329591Z [34mℹ[39m [90m「wds」[39m: webpack output is served from
I 2020-04-27T15:07:59.393494921Z [34mℹ[39m [90m「wds」[39m: Content not from webpack is served from /usr/src/app/public
I 2020-04-27T15:07:59.393641770Z [34mℹ[39m [90m「wds」[39m: 404s will fallback to /
I 2020-04-27T15:07:59.393881277Z Starting the development server...
我怀疑发生的情况是,kubernetes并没有等待足够的时间,并尝试重新启动应用程序
我没有使用deployment.yaml,只是使用GCP控制台。
我的ReactJS应用程序中没有运行状况终结点
这是kubectl描述吊舱的输出…
Name: helloworld-gke-7fd977fd94-kvrcj
Namespace: default
Priority: 0
Node: gke-helloworld-gke-default-pool-a23be758-g8q7/10.182.0.2
Start Time: Mon, 27 Apr 2020 17:15:18 +0200
Labels: app=hello
pod-template-hash=7fd977fd94
Annotations: kubernetes.io/limit-ranger: LimitRanger plugin set: cpu request for container hello-app
Status: Running
IP: 10.48.0.15
IPs: <none>
Controlled By: ReplicaSet/helloworld-gke-7fd977fd94
Containers:
hello-app:
Container ID: docker://389151ed6...
Image: gcr.io/tuition-h...
Image ID: docker-pullable://gcr.io/...
Port: 3000/TCP
Host Port: 0/TCP
State: Waiting
Reason: CrashLoopBackOff
Last State: Terminated
Reason: Completed
Exit Code: 0
Started: Mon, 27 Apr 2020 18:28:00 +0200
Finished: Mon, 27 Apr 2020 18:28:02 +0200
Ready: False
Restart Count: 19
Requests:
cpu: 100m
Environment:
PORT: 8080
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from default-token-sqpm7 (ro)
Conditions:
Type Status
Initialized True
Ready False
ContainersReady False
PodScheduled True
Volumes:
default-token-sqpm7:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-sqpm7
Optional: false
QoS Class: Burstable
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute for 300s
node.kubernetes.io/unreachable:NoExecute for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning BackOff 4m17s (x320 over 74m) kubelet, gke-helloworld-gke-default-pool-... Back-off restarting failed container
名称:helloworld-gke-7fd977fd94-kvrcj
名称空间:默认值
优先级:0
节点:gke-helloworld-gke-default-pool-a23be758-g8q7/10.182.0.2
开始时间:2020年4月27日星期一17:15:18+0200
标签:app=hello
pod模板哈希=7fd977fd94
注释:kubernetes.io/limit-ranger:LimitRanger插件集:容器hello应用程序的cpu请求
状态:正在运行
IP:10.48.0.15
IPs:
控制人:ReplicaSet/helloworld-gke-7fd977fd94
容器:
你好应用程序:
容器ID:docker://389151ed6...
图片:gcr.io/tutory-h。。。
图像ID:docker-pullable://gcr.io/...
端口:3000/TCP
主机端口:0/TCP
国家:等待
原因:仓促退却
最后状态:终止
原因:已完成
退出代码:0
开始时间:2020年4月27日星期一18:28:00+0200
完成时间:2020年4月27日星期一18:28:02+0200
就绪:错误
重新启动计数:19
请求:
中央处理器:100米
环境:
端口:8080
挂载:
/来自default-token-sqpm7(ro)的var/run/secrets/kubernetes.io/serviceCount
条件:
类型状态
初始化为True
准备错误
集装箱准备好了吗
播客预定为真
卷数:
default-token-sqpm7:
类型:Secret(由Secret填充的卷)
SecretName:default-token-sqpm7
可选:false
QoS等级:Burstable
节点选择器:
容差:node.kubernetes.io/未就绪:不执行300秒
node.kubernetes.io/不可访问:不执行300秒
活动:
从消息中键入原因年龄
---- ------ ---- ---- -------
警告后退4m17s(x320超过74m)kubelet,gke helloworld gke默认池-。。。退出重新启动失败的容器
图像是否从Kubernetes外开始?最近有很多关于npm启动的问题(指向react脚本中的一个潜在问题);请参阅例如或。是否可以共享图像或小代码作为复制示例?我在GKE没有得到同样的行为。对不起,这是一个私人形象。我注意到,使用nginx服务器而不是节点服务器对我来说是可行的。但我认为正如@DavidMaze提到的,这与react脚本有关。目前,我将使用nginx包装我的应用程序,但我需要一个合适的解决方案。