trallnag
trallnag

Reputation: 2376

Can a deployment ensure that there is never more than one pod running?

If I have a deployment with only a single replica defined, can I ensure that only ever one pod is running?

I noticed that when I do something like kubectl rollout for a very short amount of time I will see two pods in my logs.

Upvotes: 2

Views: 2924

Answers (2)

AFP_555
AFP_555

Reputation: 2608

Just use the deployment.spec.strategy.type=Recreate

It will kill all the current pods before creating new ones. Would be the same as having a 1 pod Statefulset, without misusing the Statefulset.

Upvotes: 1

Jonas
Jonas

Reputation: 128827

If I have a deployment with only a single replica defined, can I ensure that only ever one pod is running?

It sounds like you are asking for "at most one Pod" semantics. Also consider what happens when a Node becomes unresponsive.

This is point where Deployment and StatefulSet has different behavior.

Deployment

Has at least one Pod behavior, and may scale up new pods if it is unclear it at least one is running.

StatefulSet

Has at most one Pod behavior, and make sure to not scale up more pods if it is unclear if at most one is running.

Upvotes: 7

Related Questions