Add next line into ~/.bashrc
or ~/.zshrc
export KUBECONFIG=$(for YAML in $(find ${HOME}/.kube -name '*.yaml') ; do echo -n ":${YAML}"; done)
Run in PowerShell: Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Check Test-Path $PROFILE
If False than run New-Item -ItemType File -Path $PROFILE -Force
Or with one liner if (-Not (Test-Path $PROFILE)) {New-Item -ItemType File -Path $PROFILE -Force}
Ctrl+R then notepad $profile
Paste next script:
function importctx {
$list=Get-ChildItem -Path $HOME\.kube\ -Filter *.yaml -File -Name #-Recurse
$env:KUBECONFIG="$HOME\.kube\config"
foreach ($contect in $list) {
$env:KUBECONFIG=("$env:KUBECONFIG;$HOME\.kube\$contect")
}}
importctx
Now you can run k9s, kubectl, etc.