A simple CLI to switch your active Kubernetes cluster by managing the kubeconfig at ~/.kube/config.
- Package name:
kubeshift - CLI commands:
kubeshift(long form),ks(short alias)
- List available kubeconfig files in
~/.kube(YAML/YML). - Use a selected config to overwrite
~/.kube/config. - Simple, zero-dependency workflow built on Node.js.
# with npm
yarn global add kubeshift # or
npm i -g kubeshift # or
pnpm add -g kubeshiftAlternatively, run without global install:
npx kubeshift list$ kubeshift --help
$ ks --help
Scans ~/.kube and prints files ending with .yaml or .yml.
kubeshift list
# or
ks listExample output:
kubernetes clusters: [ 'cluster-a', 'staging', 'prod' ]
Select a cluster by prefix (case-sensitive). The command finds the first file whose name starts with the given value and writes its contents to ~/.kube/config.
kubeshift use staging
# or
ks use stagingIf staging.yaml exists under ~/.kube, it becomes your active kubeconfig.
- Reads
~/.kubedirectory. - Treats any
*.yaml/*.ymlfile as a candidate config. use <cluster>performs a prefix match on filenames and writes the matched file's contents into~/.kube/config.
- The match is prefix-based:
use prodmatches the first ofprod.yaml,prod-eu.yaml, etc. - If multiple files share the same prefix, the first match wins. Keep names unambiguous.
- If no match is found, the CLI prints
cluster not found: <name>. - Ensure your kubeconfig files in
~/.kubeare valid.
- Node.js 18+ recommended (ES modules). Earlier versions may work but are not officially tested.
- Access to your
~/.kubedirectory.
# install deps
pnpm install
# build once
pnpm build
# watch mode (TypeScript -> dist)
pnpm dev
# run built CLI
node dist/index.js --helpDuring development you can also link locally:
pnpm build
npm link # or pnpm link --global
kubeshift listindex.ts: CLI entry that defineslistanduse <cluster>commands.dist/index.js: Compiled output used by the published binary.
MIT