我有一个简单的角度应用程序,我试图使用Gitlab Auto Dev Ops管道设置CICD,该管道将部署到Google Cloud中的Kubernetes集群。问题在于部署阶段失败。
我已经尝试了这篇帖子https://mherman.org/blog/dockerizing-an-angular-app/
中的建议这是我的Dockerfile
#############
### build ###
#############
# base image
FROM node:12.4.0 as build
# install chrome for protractor tests
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
RUN apt-get update && apt-get install -yq google-chrome-stable
# set working directory
WORKDIR /app
# add `/app/node_modules/.bin` to $PATH
ENV PATH /app/node_modules/.bin:$PATH
# install and cache app dependencies
COPY package.json /app/package.json
RUN npm install
RUN npm install -g @angular/cli@8.1.2
# add app
COPY . /app
# run tests
# RUN ng test --watch=false
# RUN ng e2e --port 4202
# generate build
RUN ng build --output-path=dist
############
### prod ###
############
# base image
FROM nginx:1.16.0-alpine
# copy artifact build from the 'build environment'
COPY --from=build /app/dist /usr/share/nginx/html
# expose port 80
EXPOSE 80
# run nginx
CMD ["nginx", "-g", "daemon off;"]
这是我的.gitlab.yml
image: alpine:latest
variables:
# KUBE_INGRESS_BASE_DOMAIN is the application deployment domain and should be set as a variable at the group or project level.
# KUBE_INGRESS_BASE_DOMAIN: domain.example.com
TEST_DISABLED: "true"
CODE_QUALITY_DISABLED: "true"
POSTGRES_ENABLED: "false"
# POSTGRES_USER: user
# POSTGRES_PASSWORD: testing-password
# POSTGRES_ENABLED: "true"
# POSTGRES_DB: $CI_ENVIRONMENT_SLUG
# POSTGRES_VERSION: 9.6.2
KUBERNETES_VERSION: 1.11.10
HELM_VERSION: 2.14.0
DOCKER_DRIVER: overlay2
ROLLOUT_RESOURCE_TYPE: deployment
stages:
- build
- test
- deploy # dummy stage to follow the template guidelines
- review
- dast
- staging
- canary
- production
- incremental rollout 10%
- incremental rollout 25%
- incremental rollout 50%
- incremental rollout 100%
- performance
- cleanup
include:
- template: Jobs/Build.gitlab-ci.yml # https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/gitlab/ci/templates/Jobs/Build.gitlab-ci.yml
- template: Jobs/Test.gitlab-ci.yml # https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/gitlab/ci/templates/Jobs/Test.gitlab-ci.yml
- template: Jobs/Code-Quality.gitlab-ci.yml # https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/gitlab/ci/templates/Jobs/Code-Quality.gitlab-ci.yml
- template: Jobs/Deploy.gitlab-ci.yml # https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/gitlab/ci/templates/Jobs/Deploy.gitlab-ci.yml
- template: Jobs/Browser-Performance-Testing.gitlab-ci.yml # https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/gitlab/ci/templates/Jobs/Browser-Performance-Testing.gitlab-ci.yml
- template: Security/DAST.gitlab-ci.yml # https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/gitlab/ci/templates/Security/DAST.gitlab-ci.yml
- template: Security/Container-Scanning.gitlab-ci.yml # https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/gitlab/ci/templates/Security/Container-Scanning.gitlab-ci.yml
- template: Security/Dependency-Scanning.gitlab-ci.yml # https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/gitlab/ci/templates/Security/Dependency-Scanning.gitlab-ci.yml
- template: Security/License-Management.gitlab-ci.yml # https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/gitlab/ci/templates/Security/License-Management.gitlab-ci.yml
- template: Security/SAST.gitlab-ci.yml # https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/gitlab/ci/templates/Security/SAST.gitlab-ci.yml
# Override DAST job to exclude master branch
dast:
except:
refs:
- master
这些是我在gitlab中获得的日志
$ deploy
secret "production-secret" deleted
secret/production-secret replaced
Deploying new release...
Release "production" has been upgraded.
LAST DEPLOYED: Sat Jul 20 22:24:38 2019
NAMESPACE: web-ui-13409730
STATUS: DEPLOYED
RESOURCES:
==> v1/Pod(related)
NAME READY STATUS RESTARTS AGE
production-559fb8c7f8-d5j7f 0/1 ContainerCreating 0 3s
production-7cccb8f489-np2v7 0/1 Terminating 24 76m
==> v1/Service
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
production-auto-deploy ClusterIP 10.51.249.243 <none> 5000/TCP 99m
==> v1beta1/Deployment
NAME READY UP-TO-DATE AVAILABLE AGE
production 0/1 1 0 99m
==> v1beta1/Ingress
NAME HOSTS ADDRESS PORTS AGE
production-auto-deploy xxxxxx.nip.io,xxxxxx.nip.io 80, 443 99m
NOTES:
Application should be accessible at: http://xxxxx.nip.io
Waiting for deployment "production" rollout to finish: 0 of 1 updated replicas are available...
当我查看谷歌云中的节点时,我可以看到
production-559fb8c7f8-d5j7f
CrashLoopBackOff 0 CPU 0 B 0 B web-ui-13409730 17 Jul 20,2019,11:24:39 PM
我希望看到成功的管道,并且该应用程序可以在给定的URL http://xxxxx.nip.io下使用,但是部署阶段不会结束。
答案 0 :(得分:0)
是的,当我在机器上尝试时,容器运行良好。在对豆荚进行的第一次检查中,我看不到任何指示问题原因的信息,但是我是这个世界的新手,所以我可能错过了它。我将再看看并发表我的发现。