部署到GitLab中创建的Kubernetes集群中,指定后具有默认值
stages:
- build
- deploy
build:
stage: build
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
only:
- master
script:
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE
deploy:
stage: deploy
image: gcr.io/triggermesh/tm
only:
- master
environment: production
script:
- echo "$CI_REGISTRY_IMAGE"
- tm -n "$KUBE_NAMESPACE" --config "$KUBECONFIG" deploy service "$CI_PROJECT_NAME" --from-image "$CI_REGISTRY_IMAGE" --wait
在.gitlab-ci.yml
和
FROM maven:3-jdk-11
COPY . .
RUN mvn --batch-mode --update-snapshots install
ENV PORT=8080
EXPOSE 8080
CMD java -jar target/hello-world-0.1-SNAPSHOT.jar
在Dockerfile
阶段由于以下原因而失败
$ tm -n "$KUBE_NAMESPACE" --config "$KUBECONFIG" deploy service "$CI_PROJECT_NAME" --from-image "$CI_REGISTRY_IMAGE" --wait
Creating hello-world function
Waiting for hello-world ready state
2019/02/09 17:53:31 nil watch interface
ERROR: Job failed: exit code 1
该项目是一个Spring Boot应用程序。根据Google Cloud控制台,集群运行状况良好。