Greg
Greg

Reputation: 642

Does Kubernetes have facilities to support zero-downtime deploys when static assets change?

We have a requirement that no requests receive 404's when doing a rolling deploy. Currently we achieve this by deploying the new assets container to all servers before continuing with a rolling deploy. With nginx's "try_files" this ensures that as the new code is being rolled out we can serve both the old and new versions of assets. Does Kubernetes have any features to support this type of workflow?

Upvotes: 2

Views: 412

Answers (2)

Alex
Alex

Reputation: 2748

One possibility would be using Deployments. You can run a Deployment with several Replica's.

Now when you update to a new version, the Deployment takes care that one old version is removed and a new version is added one after another until your new version is fully rolled out. The rollout strategy can be

When running nginx in your Pod's for serving static files, I would suggest adding the following to your container specification:

lifecycle:
  preStop:
    exec:
      command: ["/usr/sbin/nginx", "-s", "quit"]

This will send a QUIT Signal to your nginx before the Pod is getting destroyed. This way you can be sure that no new connections get accepted by nginx, just before the server is going down.

Upvotes: 0

janetkuo
janetkuo

Reputation: 2835

You can either use Deployment API (for Kubernetes >= v1.2) or kubectl rolling-update (for < v1.2) to manage the rolling deploy of your Kubernetes Pods (each is a co-located group of containers and volumes). You'll also need to create Services for accessing those Pods (Services redirect traffic to Pods). During the rolling deploy, a user will be redirected to either the Pod with old or new versions of assets container.

Upvotes: 1

Related Questions