简体   繁体   English

Docker CD / CI工作流程的最佳实践是什么?

[英]What is the best practice for Docker CD/CI workflow?

I am pretty new to docker worlflow, and I am wondering what is the best practice to do for docker CD/CI workflow...most of the articles out right now seems to not really talk about the "deployment" part of docker, only the registration. 我对docker worlflow还是很陌生,我想知道对docker CD / CI工作流采取的最佳做法是什么...目前,大多数文章似乎并未真正谈论docker的“部署”部分,仅注册。

What I want to do: 我想做的事:

  1. Make some code changes 进行一些代码更改
  2. Push to Git 推到Git
  3. Jenkins Unit Test/EE test 詹金斯单元测试/ EE测试
  4. Jenkins builds docker image Jenkins构建Docker映像
  5. Store docker image in registry 将Docker映像存储在注册表中
  6. Run docker image on a server. 在服务器上运行docker image

In order to achieve Steps 1-5, I have the below stack. 为了实现步骤1-5,我具有以下堆栈。

User pushes to gitlab -> Gitlab webhook notifies jenkins -> jenkins builds the project -> Stores the image in the gitlab docker registry. 用户推送到gitlab-> Gitlab webhook通知jenkins-> jenkins构建项目->将映像存储在gitlab docker注册表中。

I am using Rancher for docker image deployment...I really like the distributedness of Rancher. 我正在使用Rancher进行Docker映像部署...我真的很喜欢Rancher的分布式性。 ie I can specify a docker image to run, and rancher takes care of which server to deploy my container. 也就是说,我可以指定要运行的docker映像,而rancher负责部署容器的服务器。

Ideally I would like step #6 to be "distributed" (ie i dont want to ssh into a server and run docker run {imagename} ) and have some service be the authority for deployment 理想情况下,我希望步骤6是“分布式的”(即,我不想ssh进入服务器并运行docker run {imagename} ),并拥有某些服务来进行部署

is there anything like that currently that will allow me to achieve this? 目前有什么可以让我实现的目标吗?

As to the last step, given the Rancher as an example (many others provide similar REST APIs as well), you can let Jenkins to invoke the Rancher API to do a service upgrade, provided you need to define your own stack into a Rancher custom service catalog. 关于最后一步,以Rancher为例(许多其他人也提供了类似的REST API),如果需要在Rancher自定义中定义自己的堆栈,则可以让Jenkins调用Rancher API进行服务升级。服务目录。

I am also looking for lightweight solutions and happy to know alternatives. 我也在寻找轻量级的解决方案,并且很高兴知道替代方案。

There are so many different approaches to achieve this. 有很多不同的方法可以实现这一目标。

One of the easiest one is to use a configuration management tool to orchestrate the deployment of the new images. 最简单的方法之一是使用配置管理工具来协调新映像的部署。 Ansible is a good choice, but others like puppet or chef are fine too. Ansible是一个不错的选择,但是其他人像木偶或厨师也可以。 Those tools will give you full control on what has to be deployed where. 这些工具将使您完全控制必须部署在何处的内容。 You can easily roll an update without any interruption of traffic as described in this example . 如本示例所述,您可以轻松滚动更新而不会造成任何流量中断。

Another approach consists in relying on the cluster itself to automatically deploy services. 另一种方法是依靠群集本身来自动部署服务。 This approach is usually referred as choreography. 这种方法通常称为编排。 Tools like kubernetes or the recent docker swarm with some magics are good choices. 诸如kubernetes之类的工具或最近带有一些魔术的docker swarm都是不错的选择。

As a side note, the later approach tends to a microservice architecture and seems to be more appealing but is actually more complex to implement. 顺便提一下,后一种方法趋向于微服务体系结构,似乎更有吸引力,但实现起来实际上更复杂。 It makes some assumptions on the way the services executed by the cluster are built. 它对集群执行的服务的构建方式进行了一些假设。 The first approach however will fit any kind of software. 但是,第一种方法将适合任何类型的软件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM