Permanently set the kubectl cache directory

5/10/2019

Due to a number of settings outside of my control, the default location of my kubectl cache file is on a very slow drive on my Windows PC. This ended up being the root cause for much of the slowness in my kubectl interactions.

I have a much faster location in mind. However, I can't find a way to permanently change the location; I must either temporarily alter the home directory environment variables or explicitly set it on each command.

Is there a way to alter my .kube/config file to permanently/persistently set my cache location?

-- NBJack
caching
kubectl
kubernetes
windows

1 Answer

5/11/2019

Best way for you is move the whole home directory to fast drive.

But if you don't want moving the whole directory you can set Powershell alias for your command like PS> Set-Alias -Name kubectl -Value "Path\to\kubectl --kubeconfig=PLACE_FOR_YOUR_CONFIG"

-- Vasily Angapov
Source: StackOverflow