我正在尝试将示例角度应用程序部署到 GKE。我创建了一个示例集群,在其中启用了云运行和 istio 服务
gcloud beta container clusters create new-cluster \
--addons=HorizontalPodAutoscaling,HttpLoadBalancing,Istio,CloudRun \
--machine-type=n1-standard-2 \
--cluster-version=latest \
--zone=us-east1-b \
--enable-stackdriver-kubernetes --enable-ip-alias \
--scopes cloud-platform --num-nodes 4 --disk-size "10" --image-type "COS"
以下是我的 cloudbuild.yaml 文件步骤:
# build the container image
- name: gcr.io/cloud-builders/docker
args: [ build, -t, gcr.io/$GCLOUD_PROJECT/gcp-cloudrun-gke-angular:1.01, . ]
# push the container image to Container Registry
- name: gcr.io/cloud-builders/docker
args: [ push, gcr.io/$GCLOUD_PROJECT/gcp-cloudrun-gke-angular:1.01 ]
# Deploy container image to Cloud Run
- name: gcr.io/cloud-builders/gcloud
args: [ beta, run, deploy, feedback-ui-deploy-anthos, --image, gcr.io/$GCLOUD_PROJECT/gcp-cloudrun-gke-angular:1.01, --platform, gke, --cluster, cloudrun-angular-cluster, --cluster-location, us-central1-a ]
images:
- gcr.io/$GCLOUD_PROJECT/gcp-cloudrun-gke-angular:1.01
我已经为 gcloud prj 设置了环境变量。现在,当我尝试将其部署到上面创建的 gke 集群时,我总是会遇到修订不可用错误:
Deploying new service... Configuration "service-1" does not have any ready Revision.
- Creating Revision...
X Routing traffic... Configuration "service-1" does not have any ready Revision.
这是我用来部署到云运行的命令
gcloud beta run deploy --platform gke --cluster new-cluster --image gcr.io/$GCLOUD_PROJECT/gcp-cloudrun-gke-angular:1.01 --cluster-location us-east1-b
另一个完全托管的云运行完美无缺。但是当我部署到现有的 gke 集群时,我最终会遇到错误。我通读了文档,它说如果它是一项新服务,则会自动创建修订版,不知道为什么我的服务没有发生这种情况
编辑: 这是 kubectl describe 输出。我删除了所有集群并重新创建了一个新集群,但最终还是一样。
所以在描述服务时,这就是我得到的
注意:我使用默认命名空间。不确定它是否与这个问题有任何关系。
Status:
Conditions:
Last Transition Time: 2019-12-04T12:49:59Z
Message: Revision "gke-service-00001-pef" failed with message: Container failed with: nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (2: No such file or directory)
2019/12/04 12:49:40 [emerg] 1#1: open() "/var/log/nginx/error.log" failed (2: No such file or directory)
.
Reason: RevisionFailed
Status: False
Type: ConfigurationsReady
Last Transition Time: 2019-12-04T12:49:59Z
Message: Configuration "gke-service" does not have any ready Revision.
Reason: RevisionMissing
Status: False
Type: Ready
Last Transition Time: 2019-12-04T12:49:59Z
Message: Configuration "gke-service" does not have any ready Revision.
Reason: RevisionMissing
Status: False
Type: RoutesReady
Latest Created Revision Name: gke-service-00001-pef
Observed Generation: 1
URL: http://gke-service.default.example.com
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Created 2m21s service-controller Created Configuration "gke-service"
Normal Created 2m21s service-controller Created Route "gke-service"
Normal Updated 20s (x5 over 2m21s) service-controller Updated Service "gke-service"
由于我通过 nginx 公开了 angular index.html 文件,因此这是我的配置:
server {
listen 8080 default_server;
sendfile on;
default_type application/octet-stream;
gzip on;
gzip_http_version 1.1;
gzip_disable "MSIE [1-6]\.";
gzip_min_length 1100;
gzip_vary on;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
gzip_comp_level 9;
root /usr/share/nginx/html;
location / {
try_files $uri $uri/ /index.html =404;
#proxy_pass: "http://localhost:8080/AdTechUIContent"
#uncomment to include naxsi rules
#include /etc/nginx/naxsi.rules
}
}
当我在本地构建 docker 映像并且我能够访问它时,这工作正常。以防万一,这是我的 docker 文件
FROM node:12.13-alpine as app-ui-builder
#Now install angular cli globally
RUN npm install -g @angular/cli@8.3.14
#RUN npm config set registry https://registry.cnpmjs.org
#Install git and openssh because alpine image doenst have git and all modules in npm has the dependicies which are all uploaded in git
#so to use them we need to be able git
RUN apk add --update git openssh
RUN mkdir ./app
COPY package*.json /app/
WORKDIR ./app
COPY . .
RUN npm cache clear --force && npm i
RUN ls && $(npm bin)/ng build --prod
FROM nginx:1.17.5-alpine AS nginx-builder
RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/*
COPY app-ui-nginx.conf /etc/nginx/conf.d
RUN rm -rf /usr/share/nginx/html/*
COPY --from=app-ui-builder /app/dist/app-ui /usr/share/nginx/html
RUN ls /usr/share/nginx/html
RUN chmod -R a+r /usr/share/nginx/html
EXPOSE 8080
#
CMD ["nginx", "-g", " daemon off;"]
@AhmetB 。你能告诉我为什么nginx在这里抛出错误吗
编辑: 我确实尝试使用带有部署和服务的普通 Kubectl 命令部署应用程序。它工作得很好。因此,即使可以找到该文件,也不确定使用 nginx 记录错误是否违反了哪个云运行合同