Kubernetes announced a new release in March with new GA features. I will be introducing one of them: kubectl diff. Diff command is a feature of kubernetes since v1.13. It is stable with k8s new version (v1.18).
Diff command helps you detect differences between the current live object and the new feature object. This command focuses on changes made on the object. If you want to use this feature, you have to enable its flag by running kube-apiserver --feature-gates DryRun=true on the API-server, prior to 1.13. This feature is enabled by default since 1.13.
Usage of the diff command:
You can use the diff command to check differences in a file or files in a directory:
kubectl diff -f deployment.yaml
kubectl diff -k ./dir/
If you want to select your diff command, you can use this environment variable: KUBECTL_EXTERNAL_DIFF. By default, the diff command available in your path will be run with -u (unified) and -N (treat new files as empty) options.