[英]How to update a docker swarm service with no replication with zero downtime?
I want to update docker swarm service without down-time.我想在不停机的情况下更新 docker swarm 服务。 The problem is that I don't have enough resources to have service replication.
问题是我没有足够的资源来进行服务复制。 Is there anyway to do this?
有没有办法做到这一点?
The default with swarm mode is to stop containers before starting new ones. swarm 模式的默认设置是在启动新容器之前停止容器。 There is a pull request (#30261) that was added in 17.05 to optionally start a new instance before stopping the old one.
在 17.05 中添加了一个拉取请求 (#30261) ,可以在停止旧实例之前选择启动一个新实例。 The syntax for this is:
其语法是:
docker service update --update-order start-first ...
This has not been added to updating stacks yet, you can track that request on issue #32586 .这尚未添加到更新堆栈中,您可以在问题 #32586上跟踪该请求。
Based on the documentation you can use order property on your docker-service file根据文档,您可以在 docker-service 文件中使用 order 属性
order : Order of operations during updates : order :更新期间的操作顺序:
and your docker service file will be like this你的docker服务文件会是这样的
version: '3.4'
services:
nginx:
image: nginx
restart: always
deploy:
restart_policy:
condition: on-failure
update_config:
order: start-first
make sure you are using version 3.4+ to make it work确保您使用的是 3.4+ 版以使其正常工作
https://docs.docker.com/compose/compose-file/#deploy https://docs.docker.com/compose/compose-file/#deploy
The type of deploy you want to do is called blue-green deployment.您想要执行的部署类型称为蓝绿部署。 I recommend following the steps of this blog to do it.
我建议按照此博客的步骤进行操作。
https://technologyconversations.com/2017/01/31/blue-green-deployments-with-docker-services-running-inside-a-swarm-cluster/ https://technologyconversations.com/2017/01/31/blue-green-deployments-with-docker-services-running-inside-a-swarm-cluster/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.