1. 安装gitlab-runner 这里不再介绍
2. 使用gitlab ci 工具 cicd 代码流程
代码检查--> docker build --> 更新harbor 服务器 --> 同步到kubernetes --> 发送邮件通知
在项目的主目录创建.gitlab-ci.yml 文件
stages: - scanner - sendmail - build - update_img - sync_img - deploy - check_pod - send_mail variables: namespace: "ci" deployment_name: "platform-api" project: "harbor.test.com/test/ci/platform-api" release: "latest" harbor: "http://harbor.test.com" DOCKER_HARBOR_USER: "admin" DOCKER_HARBOR_PASSWD: "Harbor12345" BASE_IMAGE: "harbor.test.com/lks/cicd/initbase:v1" DOCKER_PUSH_IMAGE: "harbor.lenovo.com/lks/cicd/dockerpush:git" KUBECTL_TOOL: "harbor.test.com/devel-tool/kubectl_tool:latest" mail_list: "test1@test.com" include: - local: ‘.gitlab/check/SonarqubeCheck.yml‘ - local: ‘.gitlab/docker/DefaultDockerBuild.yml‘ - local: ‘.gitlab/docker/PushImage.yml‘ - local: ‘.gitlab/Kubernetes/SyncImage.yml‘ - local: ‘.gitlab/Kubernetes/CheckPod.yml‘ - local: ‘.gitlab/check/SendMail.yml‘
原文:https://www.cnblogs.com/zhenhui/p/14361971.html