后端应用编译和部署
部署后端应用
- 上传代码
Git代码提交:checkout空的华为代码仓库到本地,然后将代码复制到本地目录,先然后Add 然后commit 最后push
- 修改编译命令
mvn clean install -U -pl ieo-4a/ieo-4a-biz -am -DskipTests=true -Pdev
- 修改dockerfile
基础镜像地址、APM探针检查
FROM swr.cn-east-3.myhuaweicloud.com/group-dev/java:8-jre MAINTAINER ieo@dtt.com ENV TZ=Asia/Shanghai ENV JAVA_OPTS="-Xms512m -Xmx1024m -Djava.security.egd=file:/dev/./urandom" RUN ln -sf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone && \ mkdir -p /ieo-4a && \ cd /ieo-4a && \ curl -k https://apm2-javaagent-cn-east-3.obs.cn-east-3.myhuaweicloud.com/apm_agent_install.sh -o apm_agent_install.sh && bash apm_agent_install.sh -ak tqef3mryJ45BhrRc -sk Ts66kLf8uLlGMbDlTmYZSvtMiqjIxmx8YIbgyTY4dLTkM4CrBbtfF1OcWmPX7Kg6V0C7PM68BcGY6yF7DVzTTpRS6GCI4ToIEMRd7W1nRg9Zn4voROoKX903tvYyCXxQqhrdA4pOrOaBwo2OFTjWTafiyrwsOPrE3RUEoViQSXW3XMv38nGRAPZkVO084EZt6WhfwMjuSznv2wngh2qMmbIMUqgbYGzALa73oL2kUabX3SFw0E1i0IzbANAtsVyl -masteraddress https://100.125.4.27:41333 -obsaddress https://apm2-javaagent-cn-east-3.obs.cn-east-3.myhuaweicloud.com -version latest WORKDIR /ieo-4a EXPOSE 4000 ADD ./ieo-4a/ieo-4a-biz/target/ieo-4a-biz.jar ./ CMD sleep 2;java -javaagent:/ieo-4a/apm-javaagent/apm-javaagent.jar=appName=ieo-4a,env=dev $JAVA_OPTS -Dlog4j2.formatMsgNoLookups=true -jar ieo-4a-biz.jar
- 配置部署Secret
yaml-secret=default-secret(可以先用kubectl get secret -n d-fsc)
图1 配置部署
- 修改pom.xml中的私服地址
/pom.xml <distributionManagement> <repository> <id>nexus-releases</id> <name>nexus-releases</name> <url>http://xx.xx.xx.xx:8081/repository/maven-releases/</url> </repository> <snapshotRepository> <id>nexus-snapshots</id> <name>nexus-snapshots</name> <url>http://xxx.xxx.xxx.xxx:8081/repository/maven-snapshots/</url> </snapshotRepository> </distributionManagement>
- 修改配置中心的相关配置
图2 配置管理
- 后端应用CI流水线
ieo-4a-构建镜像 mvn clean install -U -pl ieo-4a/ieo-4a-biz -am -DskipTests=true -Pdev http://xx.xx.xx.xx:8081/repository/maven-releases/ release http://xx.xx.xx.xx:8081/repository/maven-snapshots/ snapshot http://xx.xx.xx.xx:8081/repository/maven-public/ release ./ieo-4a/ieo-4a-biz/target/*.jar env_dev ieo-4a v1.1 ./ieo-4a/ieo-4a-biz/Dockerfile
图3 构建步骤1
图4 构建步骤2
图5 构建步骤3
图6 构建步骤4
图7 构建步骤5
- 后端应用CD流水线
图8 部署步骤1
图9 部署步骤2
- 后端应用访问
nodePort暴露服务 安全组放开端口
图10 入方向规则
- 启动顺序
4a启动成功后检查redis是否有gl开头的key, 如果有则启动gateway
nacos -> 4a -> auth -> gateway