Search:

New Stable Feature in Kubernetes: kubectl diff

k8s v1.13 vs k8s new version (v1.18).

New Stable Feature in Kubernetes: kubectl diff

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.

export KUBECTL_EXTERNAL_DIFF=meld kubectl diff -k ./dir/

I changed the number of replicas in deployment for the case above, and you can see the output of the diff command for differences.

 

kubectl diff

 

What is in the upcoming versions for diff?

  • Diff command is going to improve support for CRD’s.
  • Some kubectl flags are missing from the diff command, they will be added in the future.
  • kubectl diff will support remote execution on the server-side.

Kubernetes continues to improve day by day. I’m sure that the diff feature will be improved to using more kubectl flags. We are waiting excitedly for new kubernetes features and versions.

 

Halil Bozan

Infrastructure and Platform Developer at kloia