Skip to content

Commit

Permalink
Update the docs.
Browse files Browse the repository at this point in the history
Signed-off-by: corvofeng <corvofeng@gmail.com>
  • Loading branch information
corvofeng committed May 12, 2024
1 parent cd18ff1 commit ecbcabe
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 71 deletions.
26 changes: 22 additions & 4 deletions docs/en/example.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# Best Practice

## My Template Configuration

## kube-ps1 and fzf

> If you want to use kubectl with zsh, I recommend to use `kube-ps1`
https://github.com/jonmosco/kube-ps1

![kube-ps1](https://raw.githubusercontent.com/jonmosco/kube-ps1/master/img/kube-ps1.gif)

> A good search engine in the terminal
https://github.com/junegunn/fzf

```bash
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf && \
~/.fzf/install --bin && ~/.fzf/install --completion --update-rc --key-bindings --no-bash --no-fish && \
grep -q 'fzf.zsh' ~/.zshrc || echo '[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh' >> ~/.zshrc
```

## tmuxinator example template

```yaml
name: <%= @settings["project"] %>
Expand Down Expand Up @@ -31,6 +51,4 @@ windows:
In addition to modifying the context, you can also add prompts to the terminal PS1, similar to this:
https://github.com/jonmosco/kube-ps1
![image](https://github.com/corvofeng/kubemux/assets/12025071/e3a5b879-5af0-41ca-b2bf-91496ab8bcd8)
![image](https://github.com/corvofeng/kubemux/assets/12025071/e3a5b879-5af0-41ca-b2bf-91496ab8bcd8)
Binary file added docs/en/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 12 additions & 7 deletions docs/en/intro.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@

## Installation

### MacOS

```bash
# MacOS
brew install corvofeng/tap/kubemux
```

### Linux

# Linux -- using bin: https://github.com/marcosnils/bin
> Using bin: https://github.com/marcosnils/bin
```bash
bin install https://github.com/corvofeng/kubemux ~/usr/bin
# bin ls
# Path Version URL Status
# ~/usr/bin/kubemux v1.1.2 https://github.com/corvofeng/kubemux/releases/tag/v1.1.2 OK
```

# Linux -- using binary
> Using binary
```bash
cd /tmp
rm kubemux_linux_amd64.tar.gz
wget https://github.com/corvofeng/kubemux/releases/latest/download/kubemux_linux_amd64.tar.gz
tar -zxvf kubemux_linux_amd64.tar.gz
sudo install -v kubemux /usr/local/bin
```


## Usage


44 changes: 44 additions & 0 deletions docs/en/usage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# How to use kubemux


## kubeconfig

<script async src="https://asciinema.org/a/9lB50c5mndYfl0jBZLaG8ymdg.js" id="asciicast-658052" async="true"></script>

```bash
ls ~/.kube
# pve-kube.config xxx

kubemux kube --kube pve-kube.config

# I suggest you add the completion support
# source <(kubemux completion bash)
# source <(kubemux completion zsh)
# or you can add the command into the .bashrc or .zshrc.
kubemux kube --kube <tab>
```


## tmuxinator

<script src="https://asciinema.org/a/6kYCveJwVr4Sggj8QhqlsCKLm.js" id="asciicast-658053" async="true"></script>

```bash
mkdir ~/.tmuxinator

echo '
name: kubemux
root: "~/"
windows:
- p1:
- ls
- pwd
- p2:
- pwd
- echo "hello world"
- p3: htop
' > ~/.tmuxinator/kubemux.yml

kubemux -p kubemux
```

17 changes: 0 additions & 17 deletions docs/en/usage/kubeconfig.md
Original file line number Diff line number Diff line change
@@ -1,17 +0,0 @@
### kubeconfig

```bash
ls ~/.kube
# pve-kube.config xxx

kubemux kube --kube pve-kube.config

# I suggest you add the completion support
# source <(kubemux completion bash)
# source <(kubemux completion zsh)
# or you can add the command into the .bashrc or .zshrc.
kubemux kube --kube <tab>
```

<script async src="https://asciinema.org/a/9lB50c5mndYfl0jBZLaG8ymdg.js" id="asciicast-658052" async="true"></script>

24 changes: 0 additions & 24 deletions docs/en/usage/terminator.md
Original file line number Diff line number Diff line change
@@ -1,24 +0,0 @@
### tmuxinator

<script src="https://asciinema.org/a/6kYCveJwVr4Sggj8QhqlsCKLm.js" id="asciicast-658053" async="true"></script>

```bash
mkdir ~/.tmuxinator

echo '
name: kubemux
root: "~/"
windows:
- p1:
- ls
- pwd
- p2:
- pwd
- echo "hello world"
- p3: htop
' > ~/.tmuxinator/kubemux.yml

kubemux -p kubemux
```


20 changes: 9 additions & 11 deletions docs/en/why.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Why I create this tool

## Kubernetes Multi-Cluster Management Solution

Expand Down Expand Up @@ -39,7 +40,7 @@ Solution using tmux configuration file splitting:
To address these problems, I propose a solution that utilizes tmux configuration file splitting. This approach involves creating a separate tmux session for each Kubernetes cluster. Each tmux session has its own KUBECONFIG file, which allows you to operate on multiple clusters simultaneously and independently.
## tmux Multiple Sessions
## tmux
`tmux` is a powerful terminal multiplexer that allows you to create and manage multiple sessions in the same terminal window. This is very useful for managing multiple servers or clusters because you can easily switch between different sessions without opening multiple terminal windows.

Expand All @@ -63,7 +64,7 @@ tmux attach-session -t <session-name>
tmux new-session -s <session-name>
```

### tmux -L
### Multiple Sessions

In simple terms, the `-L socket-name` parameter allows you to specify the location of the tmux socket, and different sockets correspond to completely isolated sessions.

Expand All @@ -82,14 +83,16 @@ The script here can already achieve multi-cluster management. So why do we intro
2. I want the tmux session to have multiple windows with their own functionalities.


## tmuxinator Usage and Limitations
## tmuxinator

https://github.com/tmuxinator/tmuxinator

![](https://user-images.githubusercontent.com/289949/44366875-1a6cee00-a49c-11e8-9322-76e70df0c88b.gif)

It is a tool written in Ruby that allows you to define tmux terminals in YAML format. It also supports templating. Here is an example of a templated YAML file:

### Usage

```yaml
name: project
root: ~/<%= @settings["workspace"] %>
Expand All @@ -116,13 +119,8 @@ It can help me perfectly differentiate different environments, and because I use
![image](https://github.com/corvofeng/kubemux/assets/12025071/36c8a6ed-47e9-49cf-8a99-1389899b0091)


Limitations: Since it is written in Ruby, it requires a relatively new version of Ruby installed on the machine. AWS requires logging into a jump host for operations, but the machines we use are very old, and I don't want to compile and reinstall Ruby.
After a quick look at the code, I found that it doesn't use any advanced features. It would be very easy to completely rewrite it in Golang.

## Implementation of kubemux
### Limitation

For this project, I heavily relied on ChatGPT, mainly for writing the logic and unit tests. Originally, I thought it would take 2-3 days of work, but the development cycle was shortened to 1 day. The final result is also very good. After rewriting, kubemux has no dependencies and is very lightweight to install.

The project is open source here, and it should be compatible with tmuxinator configurations. If you find any missing features, feel free to open an issue.
Since it is written in Ruby, it requires a relatively new version of Ruby installed on the machine. AWS requires logging into a jump host for operations, but the machines we use are very old, and I don't want to compile and reinstall Ruby.
After a quick look at the code, I found that it doesn't use any advanced features. It would be very easy to completely rewrite it in Golang.

https://github.com/corvofeng/kubemux
8 changes: 7 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@

A tmux wrapper for managing multiple clusters and incorporating [tmuxinator](https://github.com/tmuxinator/tmuxinator).

> Most of the code is generated by ChatGPT.
For this project, I heavily relied on ChatGPT, mainly for writing the logic and unit tests. Originally, I thought it would take 2-3 days of work, but the development cycle was shortened to 1 day. The final result is also very good. After rewriting, kubemux has no dependencies and is very lightweight to install.

The project is open source here, and it should be compatible with tmuxinator configurations. If you find any missing features, feel free to open an issue.

https://github.com/corvofeng/kubemux



| English Documents | 中文文档 |
| ---- | ---- |
Expand Down
15 changes: 8 additions & 7 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ edit_uri: edit/main/docs/
nav:
- Home: index.md
- English:
- introduction: en/intro.md
- why: en/why.md
- example: en/example.md
- usage:
# - en/usage.md
- terminator: en/usage/terminator.md
- kubeconfig: en/usage/kubeconfig.md
- Introduction: en/intro.md
- Why: en/why.md
- Usage: en/usage.md
- Example: en/example.md
# - usage:
# - terminator: en/usage/terminator.md
# - kubeconfig: en/usage/kubeconfig.md
# - comments: en/comments.md
# - example snips: en/example_snips.md
# - available_commands: en/available_commands.md
Expand Down Expand Up @@ -44,6 +44,7 @@ plugins:
enable_creation_date: true

markdown_extensions:
- pymdownx.magiclink
- toc:
permalink: True
- admonition
Expand Down

0 comments on commit ecbcabe

Please sign in to comment.