In the book Kubernetes: Up & Running, on the section "Creating Deployments", it has a yaml file that is being used for deployments that starts like this:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
annotations:
deployment.kubernetes.io/revision: "1"
What's the point of setting up deployment.kubernetes.io/revision: "1"
?
This is a file that is going to be applied, not the result of querying the server.
This annotation is set by Kubernetes. It is required for deployment to identify it's respective Replicaset.
Ok, let me explain. A Deployment creates Replicaset. This Replicaset is responsible for creating Pod's.
Whenever, you made some changes in deployment's podTemplate, it creates a new replicaset. But it don't delete old replicaset as it is necessary if you want to rollback to a previous version.
Now, how deployment will know which replicaset is currently being used? Here comes the deployment.kubernetes.io/revision:
annotation. Replicaset also contains this annotation. So, deployment know which replicaset is being used by matching revision number of it's annotation with the revision number of replicaset's annotation.
You can read this nice article to understand more: How Kubernetes Deployments Work.
To know how to rollback deploymment to a previous version, see here.