skip to content
Alvin Lucillo

Set kubeconfig file

/ 1 min read

By default, kubectl uses the kube config file in this location: ~/.kube/config.

To specify another config file for temporarily when performing config command, use --kubeconfig. Example: k config use-context ctx1 --kubeconfig ~/config/.kubeconfig1

However, if you want kubectl to use a new config file permanently, you can overwrite ~/.kube/config. Alternative, you can set the the file in the $KUBECONFIG variable. To do this, modify your ~/.bashrc and export the variable with the location of the new config file (e.g., export KUBECONFIG=~/config/.kubeconfig1). After that, update your current session: source ~/.bashrc.