-4

I want to have to achieve zero downtime. I have created a service with 5 replicas and deploy into the stack then I want to update the existing service with some new changes and deploy into the stack with zero downtime.

version: "3" services: hello-html: image: hello-html:latest deploy: replicas: 5 resources: limits: cpus: "0.1" memory: 50M restart_policy: condition: on-failure ports: - 80:80 networks: mynetwork: driver: overlay

3 Answers3

0

Use Kubernetes container as a services (CAAS) to do update the application with zero downtime

mahes wari
  • 91
  • 1
0

Use docker service update - refer to https://docs.docker.com/engine/reference/commandline/service_update/ for syntax.

And use docker service ls to get a list of your services and know which one to update.

taleodor
  • 1,849
  • 1
  • 13
  • 15
0

I needed to set up the following options for my services:

--update-order start-first
--update-delay 1m # depends how long your tasks needs untill it's ready

I also had to implement a HealthCheck for my api with:

start period 1m

This way docker doesn't redirect traffic before the task is ready.

For example:

HEALTHCHECK --interval=5m --timeout=3s --start-period=1m \
  CMD curl -f http://localhost/ || exit 1
namokarm
  • 668
  • 1
  • 7
  • 20