Fill README with content

This commit is contained in:
fleaz 2025-05-31 22:07:02 +02:00
parent f52e7625c3
commit 7357a8fe76
Signed by: fleaz
GPG key ID: 935474624265FE8F

View file

@ -1 +1,46 @@
# ktx
> Plant a Tree, Have a Baby, Build a k8s context switcher
## Motivation
Like every good YAML Engineer, I'm constantly switching between half a dozen k8s clusters with a big list of namespaces in each of them. This gets cumbersume with just plain kubectl, so a big ecosystem of context switchers has evolved. I tried some of them, but I had at least one problem with each of them, so I started my own to fullfill my needs. My personal requirements for a context switcher are:
* When opening a new shell I want to be in the context I used last
* When switching context or namespace in one shell, all other shells should not be affected
## Installation
Requirements:
* kubectl, fzf and jq are installed
* Your global k8s config is in ~/.kube/config
Setup:
```shell
# Clone the repo somewhere
cd ~/repos && git clone https://git.rainbownerds.de/fleaz/ktx
# Source the ktx script in your shell config
echo "source ~/repos/ktx/ktx" >> .zshrc
# Create the required directory
mkdir ~/.kube/ktx
```
Now open a new shell and you should have `ktx` and `kn` available
## Usage
```shell
# ktx alone to get a list of all your contexts to choose from
ktx
# ktx with the name of a context to directly switch to it
ktx prod-ams1
# ktx with the name of a context and a namespace
ktx prod-ams1 monitoring
# kn alone to get a list of all namespaces in the current cluster
kn
# kn with the name of a namespace to directly switch to it
```