Reputation: 649
I see there are two ways to move back to the older deployment version. One is using rollout undo command and another option is to deploy again to the older version. Is there any difference between the two or they both are interchangeable?
Upvotes: 1
Views: 932
Reputation: 9202
Well first of all there is no direct way of option is to deploy again in kubernetes. Yes the undo way is to going back the previous version of your deployment. and command to go back is
kubectl undo deployment ABC
Upvotes: 0
Reputation: 2706
As I understood, you're asking for a difference between doing undo
and manually changing pod
definitions to the exact previous state. If that's the case - read below.
When you do a new deployment and if in that deployment your pod definitions' hash has been modified - the Deployment Controller
will create a new ReplicaSet
(let's call it A
) in order to roll out new version, but at the same time it will decrease replica count in the existing ReplicaSet
(let's call it B
) - so you have 2 ReplicaSet
s (A
, B
). How it does this - depends on rollout strategy you choose (for example: rolling updates
, blue-green deployment
and so on).
When you do kubectl rollout undo deploy <your deployment>
- the Deployment Controller
will basically decrease the number of replicas in your newly created ReplicaSet
(A
) and increase the number of replicas in the old ReplicaSet
(B
).
But, when you do, as you said: deploy again to the older version
- you basically do a new deployment, so new ReplicaSet
(C
) will be created in order to roll out your new version (even if it's not a new version), and your existing ReplicaSet
s(A
) replica count will be decreased.
So, basically the difference is the ReplicaSet
s which gets created.
Read: Deployments for more info
The whole flow is as following:
Deployment Controller
manages ReplicaSet
sReplicaSet
changes desired pod
count in etcd
Scheduler
schedules the pod
Kubelet
creates/terminates actual podsAnd all of them talk to API Server
and watch for changes in resource definitions via watch mechanism, again via API Server
Upvotes: 2
Reputation: 575
when you undo the roll out, you are updating in a way that is not reflected in source control. The preferred way is to revert your YAML and apply previous versions- then your revisions match with the tracked configuration.
kubectl rollout history deployment xyz
REVISION --> these do not reflect correctly, get a new number with undo roll-out
Upvotes: 0