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 kubeshift
Alternatively, 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 list
Example 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 staging
If staging.yaml
exists under ~/.kube
, it becomes your active kubeconfig.
- Reads
~/.kube
directory. - Treats any
*.yaml
/*.yml
file 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 prod
matches 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
~/.kube
are valid.
- Node.js 18+ recommended (ES modules). Earlier versions may work but are not officially tested.
- Access to your
~/.kube
directory.
# install deps
pnpm install
# build once
pnpm build
# watch mode (TypeScript -> dist)
pnpm dev
# run built CLI
node dist/index.js --help
During development you can also link locally:
pnpm build
npm link # or pnpm link --global
kubeshift list
index.ts
: CLI entry that defineslist
anduse <cluster>
commands.dist/index.js
: Compiled output used by the published binary.
MIT