Skip to content

Commit

Permalink
chore: update doc (#5)
Browse files Browse the repository at this point in the history
* update README.md

* update demos

* update demos
  • Loading branch information
Telemaco019 authored Jun 24, 2024
1 parent 4917979 commit 33df488
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 34 deletions.
96 changes: 72 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,18 @@

![](./docs/demo.gif)

`duplik8s` allows you to easily duplicate Kubernetes pods with overridden commands and configurations.
This is useful for testing, debugging, and development purposes.
**duplik8s** allows you to easily duplicate Kubernetes Pods with overridden commands and configurations. This is useful
for testing, debugging, and development purposes.

As you might have guessed, `duplik8s` shines when used in combination with the
amazing [k9s](https://github.com/derailed/k9s) ✨.
Check out the installation instructions below to easily load it as a k9s plugin.
Think of **duplik8s** as
[kubectl debug --copy-to](https://kubernetes.io/docs/tasks/debug/debug-application/debug-running-pod/#copying-a-pod-while-changing-its-command)
on steroids:

* **Support multiple resources**: Duplicate not just Pods, but also `Deployments` and `StatefulSets`.
* **Easy Tracking**: All duplicated resources are tagged with a duplik8s label for easy identification and cleanup.
* **Persistent Storage Handling**: Smoothly duplicate Pods mounting persistent volumes without issues.
* **Probes cleanup**: Disable liveness and readiness probes to keep the cloned Pod idle and avoid restarts.
* **User-Friendly Syntax**: straightforward syntax that simplifies the selection and duplication of resources.

## Installation

Expand All @@ -36,6 +42,16 @@ $ go install github.com/telemaco019/duplik8s/kubectl-duplicate@latest

### Use as k9s plugin

<details>
<summary><b> Demo </b></summary>

![](./docs/demo-k9s.gif)

</details>

As you might have guessed, **duplik8s** shines when used in combination with the
amazing [k9s](https://github.com/derailed/k9s) ✨.

After installing `duplik8s`, you can add it to your k9s plugins by adding the following to
your `$XDG_CONFIG_HOME/k9s/plugins.yml` file.

Expand All @@ -44,7 +60,7 @@ After reloading k9s, you should be able to duplicate Pods with `Ctrl-T`.
```yaml
# $XDG_CONFIG_HOME/k9s/plugins.yaml
plugins:
duplik8s:
duplik8s-pod:
shortCut: Ctrl-T
description: Duplicate Pod
scopes:
Expand All @@ -59,41 +75,55 @@ plugins:
- $NAMESPACE
- --context
- $CONTEXT
duplik8s-deploy:
shortCut: Ctrl-T
description: Duplicate Deployment
scopes:
- deploy
command: kubectl
background: true
args:
- duplicate
- deploy
- $NAME
- -n
- $NAMESPACE
- --context
- $CONTEXT

```

On MacOS, you can find the `plugins.yml` file at `~/Library/Application Support/k9s/plugins.yaml`.

For more information on k9s plugins, you can refer to the [official documentation](https://k9scli.io/topics/plugins).

## Use cases
## Examples

**Scenario 1**: You've got a Pod running, but it's not behaving as expected.
You need to dive in and debug the issue, maybe install some extra tools along the way.
**duplik8s** supports all the standard flags available in `kubectl`, such as `--namespace`, `--context`,
and `--kubeconfig`. You can get the full list of flags by running `kubectl duplicate --help`.

**Scenario 2**: You need to run some scripts or commands in the exact same environment as a running Pod,
including all the environment variables, secrets, and configurations.
### Duplicate a Pod

In these cases, you don't want to risk messing with the live Pod.
Instead, just use `duplik8s`! It duplicates the Pod with the same specs but keeps it idle so you can open a shell
and troubleshoot without any disruptions. 🎉
```sh
$ kubectl duplicate pod my-pod
```

Skip the hassle of manually copying configurations, changing commands, and tweaking probes.
With `duplik8s`, simply run `kubectl duplicate pod my-pod` and you're done! Want to customize? Just add flags. Easy
peasy! ⚡
The cloned Pod will be identical to the original, but with probes disabled and commands overridden to keep it idle.

Even better, if you're using `duplik8s` with `k9s`, just press `Ctrl-T` to duplicate the Pod and s to open a shell
in one of its containers. 🚀
### Interactively select a Pod to duplicate

## Examples
```sh
$ kubectl duplicate pod
```

### Duplicate a Pod
The command will prompt you to select a Pod from the list of available Pods in the specified namespace.

### Duplicate a Deployment

```sh
$ kubectl duplicate pod my-pod
$ kubectl duplicate deployment my-deployment
```

The cloned Pod will be identical to the original, but with probes disabled and commands overridden to keep it idle.

### Run a specific command in a cloned Pod

```sh
Expand All @@ -102,6 +132,24 @@ $ kubectl duplicate pod nginx-pod --command-override "/bin/sh","-c","echo Hello,

With this, you can easily duplicate a Pod and run any command you want in the new instance.

## Use cases

**Scenario 1**: You've got a Pod running, but it's not behaving as expected.
You need to dive in and debug the issue, maybe install some extra tools along the way.

**Scenario 2**: You need to run some scripts or commands in the exact same environment as a running Pod,
including all the environment variables, secrets, and configurations.

In these cases, you don't want to risk messing with the live Pod.
Instead, just use `duplik8s`! It duplicates the Pod with the same specs but keeps it idle so you can open a shell
and troubleshoot without any disruptions. 🎉

Skip the hassle of manually copying configurations, changing commands, and tweaking probes.
With `duplik8s`, simply run `kubectl duplicate pod my-pod` and you're done! Want to customize? Just add flags. Easy
peasy! ⚡

Even better, if you're using `duplik8s` with `k9s`, just press `Ctrl-T` to duplicate the Pod and s to open a shell
in one of its containers. 🚀

---

Expand Down
Binary file added docs/demo-k9s.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions docs/demo-k9s.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Output demo.gif

Set Width 2400
Set Height 1200

Set Shell zsh
Type "k9s"
Enter
Sleep 3s
Ctrl+T
Sleep 3s
Type "j"
Sleep 3s
Type "s"
Sleep 1s
Type "ls"
Enter
Sleep 2s
Type "exit"
Binary file modified docs/demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 22 additions & 10 deletions docs/demo.tape
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
Output demo.gif

Set Width 2400
Set Height 1200
Set Width 1400
Set LineHeight 1.8


Set Shell zsh
Type "k9s"

Type "kubectl duplicate deploy -n my-namespace"
Enter
Sleep 3s
Ctrl+T
Sleep 3s
Sleep 2s
Type "j"
Sleep 300ms
Type "j"
Sleep 3s
Type "s"
Sleep 1s
Type "ls"
Enter
Type "kubectl get deploy -n my-namespace"
Enter
Sleep 3s

Type "kubectl duplicate pod -n my-namespace"
Enter
Sleep 2s
Type "exit"
Type "j"
Sleep 300ms
Type "j"
Sleep 1s
Enter
Type "kubectl get pods -n my-namespace"
Enter
Sleep 3s

0 comments on commit 33df488

Please sign in to comment.