You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A simple tool to manage and switch between multiple Kubernetes configuration files. This tool allows you to dump all your kubeconfig files in a single directory and easily switch between them as well as configure the current namespace.
4
4
5
-
Available both as a standalone CLI or a `kubectl` plugin.
6
-
7
5
## Features
8
6
9
7
- Manage multiple kubeconfig files in a single directory.
10
8
- Easily switch between different Kubernetes contexts.
11
9
- Easily switch between different namespaces.
12
10
- Persistent context/namespace switching across different shells.
13
11
- Interactive prompts support fuzzy search.
14
-
- Non-destructive operations on your original kubeconfig files. `kube-switcher` will never edit those. It will only work with copies of them.
12
+
- Non-destructive operations on your original kubeconfig files. `kubectl-switch` will never edit those. It will only work with copies of them.
15
13
16
-
## Why `kube-switcher`?
14
+
## Why `kubectl-switch`?
17
15
18
-
`kube-switcher` 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:
16
+
`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:
19
17
20
-
-`kubectx`assumes 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 a sub-par workflow in my opinion and I never really liked it
18
+
-`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
21
19
-`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
22
20
23
-
What I wanted was something much simpler 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.
21
+
What 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!
24
22
25
23
## Installation
26
24
27
-
> [!TIP]
28
-
> When installing `kube-switcher`, you can use it as a `kubectl` plugin by just renaming the binary to `kubectl-switch`.
29
-
> This way, you can run it via `kubectl switch ...`
30
-
31
25
### Download Precompiled Binaries
32
26
33
-
Precompiled binaries are available for various platforms. You can download the latest release from the [GitHub Releases page](https://github.com/mirceanton/kube-switcher/releases/latest).
27
+
Precompiled 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).
34
28
35
29
1. Download the appropriate binary for your system and extract the archive.
36
30
2. Make the extracted binary executable:
37
31
38
32
```bash
39
-
chmod +x kube-switcher
33
+
chmod +x kubectl-switch
40
34
```
41
35
42
36
3. Move the binary to a directory in your PATH:
43
37
44
38
```bash
45
-
mv kube-switcher /usr/local/bin/kube-switcher
39
+
mv kubectl-switch /usr/local/bin/kubectl-switch
46
40
```
47
41
48
42
### Running via Docker
49
43
50
-
`kube-switcher` is also available as a Docker container:
44
+
`kubectl-switch` is also available as a Docker container:
vscode ➜ /workspaces/kube-switcher $ kubectl get nodes
119
+
vscode ➜ /workspaces/kubectl-switch $ kubectl get nodes
126
120
NAME STATUS ROLES AGE VERSION
127
121
cluster3 Ready control-plane 21h v1.30.0
128
122
```
129
123
130
-
4. Run the `kube-switcher namespace`/`kube-switcher ns` or `kubectl switch namespace`/`kubectl switch ns` to interactively selectyour current namespace from a list
124
+
This will literally detect the file in which that context is defined and copy-paste it to the path defined in your `KUBECONFIG`.
125
+
126
+
4. Run the `kubectl switch ns` or `kubectl switch namespace` to interactively select your current namespace from a list
vscode ➜ /workspaces/kube-switcher $ kubectl get pods
156
+
vscode ➜ /workspaces/kubectl-switch $ kubectl get pods
161
157
No resources found in kube-public namespace.
162
158
```
163
159
160
+
This will modify your currently active kubeconfig file (not the original one from `KUBECONFIGS_DIR`, but rather the copy from `KUBECONFIG`) to set the current namespace.
161
+
164
162
## License
165
163
166
164
This project is licensed under the MIT License. See the `LICENSE` file for details.
0 commit comments