How it works
How it works
Section titled “How it works”Kswitch consists of two components:
switch.sh - contains the shell function switch() which is the entry point to Kswitch.
kswitch - a go binary which is executed by the switch shell function and handles context selection and manipulation of the selected Kubeconfig file.
For a proper installation
- you have to source the
switch.shscript - make the kswitch binary available in your $PATH (the switch.sh shell script looks for the kswitch binary on the $PATH).
Flow
- User executes
$ switch(bash function available via the sourced switch.sh script) - The
switch.shscript discovers and executes the kswitch binary from the $PATH - The
kswitchbinary searches for kubeconfigs in the kubeconfig stores configured in theSwitchConfigconfiguration file. - The
kswitchbinary displays a fuzzy search for kubeconfig context names - The user selects on context name
- The
kswitchbinary creates a temporary copy of the selected kubeconfig file, sets thecurrent-contextand writes the kubeconfig to~/.kube/switch_tmp - The
kswitchbinary writes the filepath to the kubeconfig to STDOUT - The
switch.shscript captures this filepath and executesexport KUBECONFIG=</path/to/tmp/kubeconfig/file>
Each terminal window operates on its own copy of the kubeconfig file (terminal window isolation).