You can use krew
to install the plugin.
$ kubectl krew install history
You also can download the binary from release page, and put it in your PATH. You may need to allow it to be executed from the settings->Security & Privacy
dialog.
List and diff versions of deployment/daemonset/statefulset
Usage:
kubectl-history [command]
Available Commands:
diff Show a diff for different revisions of the resource
help Help about any command
list List all the revisions of the resource
Flags:
-c, --context string the context scope for the request
-h, --help help for kubectl-history
-f, --kubeconfig string path to the kubeconfig file to be used for the requests
-n, --namespace string the namespace scope for the request
-v, --v Level number for the log level verbosity
--version version for kubectl-history
Use "kubectl-history [command] --help" for more information about a command.
Use list command to list all the exit revisions: k history list -n sandbox deploy dong-web
# | CREATE TIME | NAME | DESIRED | AVAILIABE | READY
---+-------------------------------+---------------------+---------+-----------+-------
2 | 2022-07-13 17:25:14 +0800 CST | dong-web-68dc7787b7 | 2 | 2 | 2
1 | 2022-07-13 17:24:15 +0800 CST | dong-web-78b7f7cbb | 0 | 0 | 0
Add -d
to show more details: k history list -n sandbox deploy dong-web -d
# | CREATE TIME | NAME | DESIRED | AVAILIABE | READY
---+-------------------------------+-----------------------------+---------+-----------+-------
2 | 2022-07-13 17:25:14 +0800 CST | dong-web-68dc7787b7 | 2 | 2 | 2
| | └─dong-web-68dc7787b7-6ggpd | | |
| | └─dong-web-68dc7787b7-z9dbl | | |
1 | 2022-07-13 17:24:15 +0800 CST | dong-web-78b7f7cbb | 0 | 0 | 0
The command below will get the same result
k history diff -n sandbox deploy dong-web
show difference between the latest two versionsk history diff -n sandbox deploy dong-web 1
show difference between version 1 and the latest versionk history diff -n sandbox deploy dong-web 1 2
show different between version 1 and 2
--- OLD
+++ NEW
@@ -4,13 +4,13 @@
annotations:
deployment.kubernetes.io/desired-replicas: "2"
deployment.kubernetes.io/max-replicas: "3"
- deployment.kubernetes.io/revision: "1"
- generation: 3
+ deployment.kubernetes.io/revision: "2"
+ generation: 2