Can not define a Kubernetes StateFul-Set with Recreate strategy

9/20/2019

I came over something I do not quite understand. When having my Deployments I can define a strategy. Either as Recreate or RollingUpdate. See this article: https://www.weave.works/blog/kubernetes-deployment-strategies

But now I have a StateFul Set which is not accepting the keyword strategy but wants to have updateStrategy. When trying to pass the type Recreate I am getting this error (from Helm):

Error: StatefulSet.apps "businessmanager-dev-prom-business-manager-set" is invalid: spec.updateStrategy: Invalid value: apps.StatefulSetUpdateStrategy{Type:"Recreate", RollingUpdate:(*apps.RollingUpdateStatefulSetStrategy)(0xc43d534178)}: must be 'RollingUpdate' or 'OnDelete'
Error: UPGRADE FAILED: StatefulSet.apps "businessmanager-dev-prom-business-manager-set" is invalid: spec.updateStrategy: Invalid value: apps.StatefulSetUpdateStrategy{Type:"Recreate", RollingUpdate:(*apps.RollingUpdateStatefulSetStrategy)(0xc43d534178)}: must be 'RollingUpdate' or 'OnDelete'

This tells me I am not allowed to use Recreate. Why is it not allowed to have the Recreate strategy used in a Stateful Set and why do I have to use updateStrategy rather than strategy? This looks for me like some deprecated behaviour.

-- xetra11
kubernetes

1 Answer

9/20/2019

For stateful sets you can implement Blue/Green update, Rolling update, OnDelete strategy.

Stateful sets used when you are running stateful application inside pod. For example storing something in RAM. redis database run as stateful sets.

Stateful sets managed the sequence automatically like example 'redis-0','redis-1' so if anything goes wrong to pod it will close the process and start new process and try to manage the same state.

If you use strategy Recreate it will delete pod first terminate it and again start the new one it's for stateless applications. Also same way works for Rolling update.

-- Harsh Manvar
Source: StackOverflow