标签:自动 push entry dmi var pod get mode 操作
项目使用的其他软件,比如redis,nacos,mysql,rabbitmt,emqx,nexus等都是外置的,不部署到k8s中
需要在项目每个模块的根目录下编写Dockerfile文件
Dockerfile文件参考这篇文章:https://www.cnblogs.com/sanduzxcvbnm/p/14950753.html
FROM jdd.io/jre:1.8.0_275
MAINTAINER 1103324414@qq.com
EXPOSE 8080
ADD target/gateway-1.0.0.jar gateway.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom", "-jar", "gateway.jar"]
CMD ["--spring.profiles.active=test"]
说明:
1.jdd.io/jre:1.8.0_275镜像为自己自定义的镜像,具体制作办法参考网址:https://www.cnblogs.com/sanduzxcvbnm/p/13220054.html
项目代码是在gitlab上,使用gitlab-runner来作为CI/CD工具,不使用jenkins.
gitlab-runner的安装,跟gitlab上的项目进行构造关联,参考文章网址:https://www.cnblogs.com/sanduzxcvbnm/p/13815594.html
variables:
DOCKER_DRIVER: overlay2
MAVEN_CLI_OPTS: "-s .m2/settings.xml --batch-mode"
MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"
# CURRENT_PROJECT: jdd-parking-cloud-admin # 单个项目使用,放弃这个变量,使用全局变量:$CI_PROJECT_NAME
cache:
paths:
- .m2/repository/
stages:
- package
- build
maven_step:
tags:
- maven
stage: package
script:
- mvn clean package -Dmaven.test.skip=true # 编译整个项目
artifacts:
paths:
- target/*.jar # 注意这行,供下面的docker使用
only:
- prod
develop_docker_step:
tags:
- docker
stage: build
script:
- export TAG=`date "+%Y%m%d%H%M%S"`
# 推送到nexus仓库
- docker build -t registry.kubeoperator.io:8083/jdd-k8s/$CI_PROJECT_NAME:$TAG .
- docker login -u admin -p 7b98a6ed9mxjXa594f6 registry.kubeoperator.io:8083
- docker push registry.kubeoperator.io:8083/jdd-k8s/$CI_PROJECT_NAME:$TAG
- docker rmi registry.kubeoperator.io:8083/jdd-k8s/$CI_PROJECT_NAME:$TAG
# 推送到阿里云镜像仓库,事先在gitlab上配置好仓库环境变量
# - docker build -t "${CI_REGISTRY}"/jdd-resp/$CI_PROJECT_NAME:$TAG .
# - docker login -u "${CI_REGISTRY_USER}" -p "${CI_REGISTRY_PASSWORD}" "${CI_REGISTRY}"
# - docker push "${CI_REGISTRY}"/jdd-resp/$CI_PROJECT_NAME:$TAG
# - docker rmi "${CI_REGISTRY}"/jdd-resp/$CI_PROJECT_NAME:$TAG
only:
- prod
参考文章:https://www.cnblogs.com/sanduzxcvbnm/p/13098712.html
https://www.cnblogs.com/sanduzxcvbnm/p/13099635.html
参考网址:https://kubeoperator.io/docs/index.html
参考网址:https://kuboard.cn/install/v3/install.html
注意nacos注册/配置中心,容器ConfigMap和参数设置
参考网址:https://kuboard.cn/learning/k8s-practice/spring-blade/deploy/blade-admin.html#创建-deployment
https://www.cnblogs.com/sanduzxcvbnm/p/13207317.html
https://www.cnblogs.com/sanduzxcvbnm/p/14932097.html
需要添加到.gitlab-ci.yml文件中
从头改造springcloud框架项目部署到k8s上最佳实践操作
标签:自动 push entry dmi var pod get mode 操作
原文地址:https://www.cnblogs.com/sanduzxcvbnm/p/14950980.html