Skip to content

Instantly share code, notes, and snippets.

@BorysVrublevskyi
Last active February 8, 2023 18:29
Show Gist options
  • Save BorysVrublevskyi/9c010484d4c6772540884aa084db70c4 to your computer and use it in GitHub Desktop.
Save BorysVrublevskyi/9c010484d4c6772540884aa084db70c4 to your computer and use it in GitHub Desktop.
Script to import all *.yaml Kubernetes configs. Works only in the current terminal.
# export KUBECONFIG=$(for YAML in $(find ${HOME}/.kube -name '*.yaml') ; do echo -n ":${YAML}"; done) # bash example
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 run k9s, kubectl, whatever)
# To have this changes globally, run in PowerShell and save this code with:
# Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
# notepad $profile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment