'How to ensure that at least 3 pods are always running even if there are any rolling updates in Kubernetes

I have deployed an application in k8s cluster with 8 replicas. but how to ensure that there will be at least 3 pods always running during rolling update, can anyone please suggest a solution ?

Thanks in advance.



Solution 1:[1]

you can set the required values on maxSurge and maxUnavailable

  strategy:
    rollingUpdate:
       maxSurge: 25%
       maxUnavailable: 50%
    type: RollingUpdate

setting maxUnavailable to 50% will make sure that you always have 4 pods running.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Preet Sindhal