To help you provision, operate, and maintain Tanzu Kubernetes clusters, specify a default text editor for kubectl .

Purpose

After you provision a Tanzu Kubernetes cluster you need to maintain it. Typical maintenance tasks include upgrading the Kubernetes version and scaling cluster nodes. To perform such tasks you update the cluster manifest.

The most convenient way to update the manifest for a provisioned cluster is to use the kubectl edit command. This command opens the Kubernetes manifest in a text editor of your choice. When you save the changes, Kubernetes automatically applies the changes and updates the cluster.

To use the kubectl edit command, create a KUBE_EDITOR environment variable and specify your preferred text editor as the variable value. In addition, append the watch flag (-w) to the value so that kubectl knows when you have committed (saved) your changes.

Windows

On Windows, create a system environment variable named KUBE_EDITOR with the value set to the path of your preferred text editor. Append the watch flag (-w) to the value.

For example, the following environment variable sets Visual Studio Code as the default text editor for kubectl and includes the watch flag so that Kubernetes knows when you save your changes:

KUBE_EDITOR=code -w

Mac OS

On Mac OS, create an environment variable named KUBE_EDITOR with the value set to the path of your preferred text editor. Append the watch flag (-w) to the value so that kubectl knows when you have committed (saved) your changes.

For example, the following addition to the .bash_profile sets Sublime as the default text editor for kubectl and includes the watch flag so kubectl knows when you have saved any changes.

export KUBE_EDITOR="/Applications/Sublime.app/Contents/SharedSupport/bin/subl -w"

Linux

On Linux (Ubuntu, for example), typically the default command-line EDITOR is Vim. If so, no further action is needed to use the kubectl edit command. If you want to use a different editor, create an environment variable named KUBE_EDITOR with the value set to the path of your preferred text editor.