6 - Pipeline(CI/CD)
把软件交付过程分成几个不同的阶段,使开发人员能够尽可能快速、高效地提供新的软件。在Rancher中,您可以为每个Rancher项目配置。
阶段:
- 克隆:
每次将代码推送到存储库时,都会自动克隆存储库到本地。
- 编译:
代码克隆完成后,根据编译参数自动进行代码编译。在编译过程中,通常会通过自动化工具来对代码的进行测试。
- 构建:
编译完成并生成执行文件后,利用文件自动构建镜像。
- 推送:
镜像构建完成后,它会自动发布到Docker镜像仓库。
- 部署:
Rancher Pipeline提供简单的CI/CD体验。使用它自动签出代码、运行构建、执行测试、发布docker镜像,以及将应用部署到Kubernetes集群。
您可以在Rancher中为每个项目配置Pipeline,每个项目都可以有单独的配置和设置。
用户可以通过以下任一方式读取和编辑管道配置:
- 使用Git CLI等工具更新存储库中的配置,以使用最新的CI定义触发构建。
Rancher pipelines目前支持GitHub和GitLab(从Rancher v2.1.0开始提供)。
在某个项目中配置pipeline时,将自动创建专门用于pipeline的命名空间并部署以下组件:
- Jenkins:
- Docker Registry:
Out-of-the-box, the default target for your build-publish step is an internal Docker Registry. However, you can make configurations to push to a remote registry instead. The internal Docker Registry is only accessible from cluster nodes and cannot be directly accessed by users. Images are not persisted beyond the lifetime of the pipeline and should only be used in pipeline runs. If you need to access your images outside of pipeline runs, please push to an external registry.
- Minio:
Minio存储用于存储Pipeline执行的日志。
After you configure a pipeline, you can trigger it using different methods:
- 手动:
After you configure a pipeline, you can trigger a build using the latest CI definition from either Rancher UI or Git CLI. When a pipeline execution is triggered, Rancher dynamically provisions a Kubernetes pod to run your CI tasks and then remove it upon completion.
To use this automation, webhook management permission is required for the repo. Therefore, when users authenticate and fetch their repositories, only those on which they have admin permission will be shown.