kubernetes: Deployment with Recreate Strategy status incorrect when rolling out
What happened?
When I update a Deployment with Recreate Strategy. Its conditions remains Complete (when status.observedGeneration == spec.generation) until the older ReplicaSet finished scaled to 0.
What did you expect to happen?
According to the doc https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#progressing-deployment, Kubernetes marks a Deployment as Progressing, when The Deployment is scaling down its older ReplicaSet(s)
I.E. the Reason field of the Progressing condition should not be NewReplicaSetAvailable
How can we reproduce it (as minimally and precisely as possible)?
Create a simple deployment with Recreate Strategy:
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp
namespace: test
spec:
selector:
matchLabels:
app: myapp
strategy:
type: Recreate
template:
metadata:
labels:
app: myapp
dummy: dummy
spec:
containers:
- name: myapp
image: nginx:1.15.8
Open another console to watch on the deployment:
kubectl -n test get deploy -o yaml -w
Then update the podtemplate of the deployment
kubectl -n test patch deploy myapp -p '{"spec": {"template": {"metadata": {"labels": {"dummy": "dummy2"}}}}}'
Check the output of the watch
Anything else we need to know?
The watch output of the deployment: watch.log
And about the solution, maybe we should add a new reason like OldReplicaSetScalingDown
Kubernetes version
$ kubectl version
# paste output here
Client Version: version.Info{Major:"1", Minor:"25", GitVersion:"v1.25.4", GitCommit:"872a965c6c6526caa949f0c6ac028ef7aff3fb78", GitTreeState:"clean", BuildDate:"2022-11-09T13:36:36Z", GoVersion:"go1.19.3", Compiler:"gc", Platform:"darwin/amd64"}
Kustomize Version: v4.5.7
Server Version: version.Info{Major:"1", Minor:"24+", GitVersion:"v1.24.8-eks-ffeb93d", GitCommit:"abb98ec0631dfe573ec5eae40dc48fd8f2017424", GitTreeState:"clean", BuildDate:"2022-11-29T18:45:03Z", GoVersion:"go1.18.8", Compiler:"gc", Platform:"linux/amd64"}
Cloud provider
OS version
# On Linux:
$ cat /etc/os-release
# paste output here
$ uname -a
# paste output here
# On Windows:
C:\> wmic os get Caption, Version, BuildNumber, OSArchitecture
# paste output here
Install tools
Container runtime (CRI) and version (if applicable)
Related plugins (CNI, CSI, …) and versions (if applicable)
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 18 (13 by maintainers)
I’ve confirmed this behavior, and I think that it does not match the documented behavior.
Currently, the deployment with
Recreatestrategy doesn’t updateProgressingtype condition during its scale-down.I believe this is the code that makes this behavior.
https://github.com/kubernetes/kubernetes/blob/090025f5e6525b77017c6874b96e2569a6a597c4/pkg/controller/deployment/progress.go#L45-L52
This is not correct for the deployment with
Recreatestrategy as it only has one active replica set during its scale-down./triage accepted