【问题标题】:Cloud Run error when deploying to GKE, works with cloud run managed部署到 GKE 时出现 Cloud Run 错误,适用于 Cloud Run managed
【发布时间】:2020-04-18 20:06:33
【问题描述】:

我有一个问题,将 Angular 8 应用程序部署到 Google Cloud Run Managed 效果很好。将相同的应用程序部署到 Google Cloud Run Kubernetes 集群时出错。 任何关于两者之间可能有什么不同的帮助将不胜感激?

基本上,我正在尝试复制谷歌教程,用我的 Angular 应用程序替换前端。 [https://cloud.google.com/solutions/authenticating-cloud-run-on-gke-end-users-using-istio-and-identity-platform]

我的Dockerfile如下

FROM node:latest as node
WORKDIR /app
COPY . .
RUN npm install
RUN npm run build --prod

ENV PORT=8080

FROM nginx:alpine
COPY --from=node /app/dist/streamin-app/ /usr/share/nginx/html/
COPY nginx.conf /etc/nginx/
EXPOSE 8080
CMD ["nginx", "-g", "daemon off;"]

我的nginx.conf如下:

# on alpine, copy to /etc/nginx/nginx.conf
user                            root;
worker_processes                auto;

error_log                       /var/log/nginx/error.log warn;

events {
    worker_connections          1024;
}

http {
    include                     /etc/nginx/mime.types;
    default_type                application/octet-stream;
    sendfile                    off;
    access_log                  off;
    keepalive_timeout           3000;
    server {
        listen                  8080;
        root                    /usr/share/nginx/html;
        index                   index.html;
        server_name             0.0.0.0;
        client_max_body_size    16m;
    }
}

感谢Cloud Run error: Container failed to start 中的答案,这在云运行托管实例中部署和运行良好

gcloud run deploy frontend --image gcr.io/$GOOGLE_PROJECT/$IMAGE --platform managed

但是,当我尝试部署到 GKE 集群时,它失败了。因此,如果有人有想法,我会为 gke 缺少一些东西。

ZONE=us-central1-c
CLUSTER=cloud-run-gke-auth-tutorial

gcloud config set compute/zone $ZONE
gcloud config set run/cluster $CLUSTER
gcloud config set run/cluster_location $ZONE

kubectl create namespace public

gcloud run deploy frontend --namespace public --image gcr.io/$GOOGLE_PROJECT/$IMAGE --platform gke

错误是

Configuration "frontend" does not have any ready Revision.

日志中有一些额外的细节

[emerg] 1#1: open() "/var/log/nginx/error.log" failed (2: No such file or directory)

谢谢, 罗南

【问题讨论】:

    标签: angular dockerfile google-kubernetes-engine google-cloud-run


    【解决方案1】:

    错误表明 /var/log/nginx/error.log 不存在。

    你应该尝试创建文件或nginx目录:

     cd /var/log/nginx/
     sudo touch error.log
     sudo chmod 750 *.log
    

    在这里您可以找到相关的 SO 问题 linklink

    【讨论】:

      猜你喜欢
      • 2021-05-31
      • 2019-09-27
      • 1970-01-01
      • 2021-12-06
      • 2021-04-13
      • 2023-02-03
      • 2019-10-13
      • 2023-02-26
      • 2022-12-05
      相关资源
      最近更新 更多