https://github.com/cpg314/pv_inspect
Mount a Kubernetes PersistentVolumeClaim volume on a new pod, shell into it, and mount it via SSHFS
https://github.com/cpg314/pv_inspect
data-volume kubernetes pvc rust samba-server
Last synced: 4 months ago
JSON representation
Mount a Kubernetes PersistentVolumeClaim volume on a new pod, shell into it, and mount it via SSHFS
- Host: GitHub
- URL: https://github.com/cpg314/pv_inspect
- Owner: cpg314
- License: apache-2.0
- Created: 2024-05-11T18:25:13.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-02-26T22:13:11.000Z (over 1 year ago)
- Last Synced: 2026-01-02T00:41:19.547Z (5 months ago)
- Topics: data-volume, kubernetes, pvc, rust, samba-server
- Language: Rust
- Homepage: https://c.pgdm.ch/code
- Size: 43.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# pv_inspect
Small utility to "shell into" a Kubernetes volume and mount it locally if desired.
This allows easily inspecting or accessing volumes, even when they are not already mounted.
This works by automatically:
- Creating a new pod with the volume attached.
- Opening a shell into the pod.
- Optionally mounting the volume locally via SSHFS, after port forwarding on an OpenSSH server running on the pod.
- Deleting the pod when the tool is exited.
## Installation
See the packages on the [releases page](https://github.com/cpg314/pv_inspect/releases).
Alternatively, compile with cargo:
```console
$ cargo install --git https://github.com/cpg314/pv_inspect
```
## Usage
```
Mount a PVC on a new pod, shell into it, and mount it (via SSHFS) if desired
Usage: pv_inspect [OPTIONS] [NAME]
Arguments:
[NAME] Name of the PVC to inspect. If not provided, a list will be shown.
Options:
-n, --namespace [default: default]
-m, --mountpoint
--rw Mount the volume in read/write mode rather than read only
--nowait Do not wait until the pod has been deleted
--cleanup Cleanup stale pv_inspect pods and exit
--cleanup-min Age in minutes to cleanup pods [default: 240]
-h, --help Print help
-V, --version Print version
```
For example:
```console
$ pv_inspect -n mynamespace --rw mypvc
$ # Mount locally
$ pv_inspect -n mynamespace --rw -m ~/mounts/volume mypvc
```
### As a `k9s` plugin
If you use the [k9s Kubernetes TUI](https://k9scli.io/), you can install `pv_inspect` as a plugin by editing your plugins configuration (see the output of `k9s info`) as follows:
```yaml
plugins:
pv_inspect:
shortCut: p
description: pv_inspect
scopes:
- pvc
command: pv_inspect
args:
- -n
- $NAMESPACE
- $NAME
```
When viewing `PersistentVolumeClaims`, the `p` key (or any other you might choose) will launch `pv_inspect`:

## Cleanup
The `--cleanup` command allows delete `pv_inspect` dangling pods, due to the client aborting before deletion. It can also be executed on the cluster as a cronjob, see [`cleanup_job.yaml`](cleanup_job.yaml).
## TODO
- `rsync`-style subcommand.