Kubernetes deployment strategy to wait for all replicas

8/13/2019

I got one service with auto scaling which means it can have 2 pods or 4 pods running. My issue is that this service is a reactjs application with service-worker.

With my current deployment strategy it will create a new pod and kill one at a time, which causes issues when the clients gets alarmed that there is a new update & tries to fetch new assets from server & the loadbalancer forwards it to the old pods.

So basicly I am wondering if it's possible to change to a strategy that creates x pods & replaces them all at the same time?

-- Joelgullander
kubernetes
kubernetes-pod

3 Answers

8/13/2019

add the spec.strategy.type in your deployment.yaml manfest and set it to "Recreate" this will kill all the existing pods before new ones are created.

spec:
  strategy:
    type: Recreate

The strategy you are using is the - RollingUpdate , which is the default if you dont specify any.

-- RAMNEEK GUPTA
Source: StackOverflow

8/14/2019

Follow this approach though it is manual and meets your requirement.

Say, you are running version 1.0 ( with label version:1.0 ) in the cluster and you want to upgrade to version 2.0

  1. Deploy version 2.0 with label version:2.0
  2. Verify that pods are running and your version 2.0 app is running fine.
  3. edit version 1.0 service selector to use label version:2.0
  4. Delete version 1.0 deployment
-- P Ekambaram
Source: StackOverflow

8/13/2019

Use the Recreate deployment strategy to first kill all old pods and then create new ones.

Alternatively, if you're looking to first create a parallel set of new pods, reroute traffic to these new pods and then kill the old pods (i.e., a blue/green deployment), check this guide.

-- Aleksi
Source: StackOverflow