{"id":17443312,"url":"https://github.com/mirceanton/kubectl-switch","last_synced_at":"2026-04-17T02:02:01.004Z","repository":{"id":176088022,"uuid":"654955444","full_name":"mirceanton/kubectl-switch","owner":"mirceanton","description":"A simple tool to help manage multiple kubeconfig files","archived":false,"fork":false,"pushed_at":"2026-03-27T12:15:18.000Z","size":715,"stargazers_count":57,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-03-27T12:41:38.603Z","etag":null,"topics":["cli","cli-app","kubectl","kubectl-command","kubectl-plugin","kubectl-plugins","kubernetes","kubernetes-cluster","kubernetes-context"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mirceanton.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/funding.yml","license":"LICENSE","code_of_conduct":".github/Code_of_Conduct.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["mircea-pavel-anton"]}},"created_at":"2023-06-17T12:49:40.000Z","updated_at":"2026-03-26T21:10:13.000Z","dependencies_parsed_at":"2024-08-20T22:45:46.755Z","dependency_job_id":"c02f93c2-47ff-4fde-9d08-79f2884efcfd","html_url":"https://github.com/mirceanton/kubectl-switch","commit_stats":null,"previous_names":["mirceanton/kswitcher","mircea-pavel-anton/kswitcher","mirceanton/kube-switcher","mirceanton/kubectl-switch"],"tags_count":51,"template":false,"template_full_name":null,"purl":"pkg:github/mirceanton/kubectl-switch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mirceanton%2Fkubectl-switch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mirceanton%2Fkubectl-switch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mirceanton%2Fkubectl-switch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mirceanton%2Fkubectl-switch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mirceanton","download_url":"https://codeload.github.com/mirceanton/kubectl-switch/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mirceanton%2Fkubectl-switch/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31290993,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-01T13:12:26.723Z","status":"ssl_error","status_checked_at":"2026-04-01T13:12:25.102Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","cli-app","kubectl","kubectl-command","kubectl-plugin","kubectl-plugins","kubernetes","kubernetes-cluster","kubernetes-context"],"created_at":"2024-10-17T17:00:30.853Z","updated_at":"2026-04-01T18:59:32.907Z","avatar_url":"https://github.com/mirceanton.png","language":"Go","funding_links":["https://github.com/sponsors/mircea-pavel-anton"],"categories":["Go"],"sub_categories":[],"readme":"# kubectl-switch\n\n`kubectl-switch` is a command-line tool for managing and switching between multiple Kubernetes configuration files located in the same directory. It simplifies the process of selecting a Kubernetes context from multiple kubeconfig files and updating the active configuration or namespace.\n\nJust dump all your `kubeconfigs` into a single dir and let `kubectl-switch` manage them for you!\n\n## Features\n\n- **Multiple kubeconfig files**: Manage multiple kubeconfig files in a single directory without merging them\n- **Context \u0026 namespace switching**: Switch between contexts and namespaces from multiple config files\n- **Interactive \u0026 non-interactive modes**: Select from a list or specify directly as an argument (with tab completion support!)\n\n## Why `kubectl-switch`?\n\n`kubectl-switch` is an alternative to tools like `kubectx`, `kubens` and `kubie`. It has been created because I feel all of those fall short in certain regards:\n\n- `kubectx` and `kubens` assume all your contexts are defined in a single config file. Yes, there is some hackery you can do to your `KUBECONFIG` environment variable to make it work with multiple files, but it is (in my opinion) a sub-par workflow and I never really liked it\n- `kubie` spawns a new shell when you use it to change contexts, making it practically impossible to integrate into scripts or taskfile automation. Also I consider it to be too complicated of a solution for what is fundamentally a really simple problem\n\nWhat I wanted was something very simple conceptually: I just want to dump all my `kubeconfig` files in a single directory and then have my tool parse them and \"physically\" move over the config file to `.kube/config` (or whatever is configured in my `KUBECONFIG` env var) such that it is also persistent between different shells. Here is where `kubectl-switch` comes in!\n\n## Installation\n\n### Install via go install\n\nInstall the latest stable version directly using Go:\n\n```bash\n# Install the latest version\ngo install github.com/mirceanton/kubectl-switch/v2@latest\n\n# Or install a specific version\ngo install github.com/mirceanton/kubectl-switch/v2@v2.2.6\n```\n\n\u003e **Note**: Versions prior to v2.2.6 cannot be installed via `go install` due to module path issues. If you need an older version, please use one of the alternative installation methods below.\n\n### Download Precompiled Binaries\n\nPrecompiled binaries are available for various platforms. You can download the latest release from the [GitHub Releases page](https://github.com/mirceanton/kubectl-switch/releases/latest).\n\n1. Download the appropriate binary for your system and extract the archive.\n2. Make the extracted binary executable:\n\n   ```bash\n   chmod +x kubectl-switch\n   ```\n\n3. Move the binary to a directory in your PATH:\n\n   ```bash\n   mv kubectl-switch /usr/local/bin/kubectl-switch\n   ```\n\n### Install via Homebrew\n\n1. Add the tap\n\n   ```bash\n   brew tap mirceanton/taps\n   ```\n\n2. Install `kubectl-switch`\n\n   ```bash\n   brew install kubectl-switch\n   ```\n\n### Running via Docker\n\n`kubectl-switch` is also available as a Docker container:\n\n```bash\ndocker pull ghcr.io/mirceanton/kubectl-switch\n```\n\nTo use it with your local kubeconfig files:\n\n```bash\ndocker run -v ~/.kube:/root/.kube -v /path/to/kubeconfigs:/kubeconfigs \\\n    -e KUBECONFIG_DIR=/kubeconfigs \\\n    ghcr.io/mirceanton/kubectl-switch context\n```\n\n### Build from Source\n\n1. Clone the repository:\n\n   ```bash\n   git clone https://github.com/mirceanton/kubectl-switch\n   cd kubectl-switch\n   ```\n\n2. Build the tool:\n\n   ```bash\n   go build -o kubectl-switch\n   ```\n\n3. Move the binary to your PATH:\n\n   ```bash\n   mv kubectl-switch /usr/local/bin/kubectl-switch\n   ```\n\n## Usage\n\n### Context Command\n\nThe `context` (or `ctx`) subcommand is used to switch between Kubernetes contexts (think of `kubectx`):\n\n```bash\n# Interactive mode - select context from a list\nkubectl-switch context\n\n# Switch to a specific context\nkubectl-switch ctx my-context\n```\n\n### Namespace Command\n\nThe `namespace` (or `ns`) subcommand is used to switch the current namespace (think of `kubens`):\n\n```bash\n# Interactive mode - select namespace from a list\nkubectl-switch namespace\n\n# Switch to a specific namespace\nkubectl-switch ns kube-system\n```\n\n### Quickly Switch to Previous Configuration\n\nSwitch back to the previous configuration:\n\n```bash\nkubectl-switch -\n```\n\n### Usage with kubectl plugin\n\nWhen installed as a kubectl plugin, you can use it directly with the `kubectl` command:\n\n```sh\n# These commands are equivalent\nkubectl-switch ctx\nkubectl switch ctx\n```\n\n## Configuration\n\n`kubectl-switch` uses Viper for configuration management, allowing you to configure the tool via command-line flags or environment variables, with flags taking precedence.\n\n### Configuration Options\n\n| Option               | Flag               | Environment Variable | Default            | Description                                                       |\n| -------------------- | ------------------ | -------------------- | ------------------ | ----------------------------------------------------------------- |\n| Kubeconfig Directory | `--kubeconfig-dir` | `KUBECONFIG_DIR`     | `~/.kube/configs/` | Directory containing your kubeconfig files                        |\n| Kubeconfig           | `--kubeconfig`     | `KUBECONFIG`         | `~/.kube/config`   | Path to the currently active kubeconfig file                      |\n| Log Level            | `--log-level`      | `LOG_LEVEL`          | `info`             | Logging verbosity (trace, debug, info, warn, error, fatal, panic) |\n| Log Format           | `--log-format`     | `LOG_FORMAT`         | `text`             | Log output format (text, json)                                    |\n| Page Size            | `--page-size`      | `PAGE_SIZE`          | `10`               | Number of items to show per page in selection prompts             |\n\n## Shell Completion\n\nThe `completion` subcommand generates shell completion scripts:\n\n```bash\n# Generate completions for bash\nkubectl-switch completion bash \u003e /etc/bash_completion.d/kubectl-switch\n\n# Generate completions for zsh\nkubectl-switch completion zsh \u003e ~/.zsh/completion/_kubectl-switch\n\n# Generate completions for fish\nkubectl-switch completion fish \u003e ~/.config/fish/completions/kubectl-switch.fish\n\n# Generate completions for powershell\nkubectl-switch completion powershell \u003e ~/kubectl-switch.ps1\n```\n\n## Contributing\n\nContributions are welcome! Please fork the repository, make your changes, and submit a pull request.\n\n## License\n\nThis project is licensed under the MIT License. See the [`LICENSE`](./LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmirceanton%2Fkubectl-switch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmirceanton%2Fkubectl-switch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmirceanton%2Fkubectl-switch/lists"}