Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions .krew.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,14 @@ spec:
arch: arm64
{{addURIAndSha "https://github.com/machine424/vifal/releases/download/{{ .TagName }}/kubectl-vifal_{{ .TagName }}_darwin_arm64.tar.gz" .TagName }}
bin: kubectl-vifal
shortDescription: exposing and unifying Kubernetes container filesystems locally
shortDescription: Expose and unify container filesystems locally
description: |
FUSE mount that exposes and unifies Kubernetes container filesystems locally.
Browse namespaces, pods, and containers as directories, read files, and diff
configs across pods using standard shell tools.
FUSE filesystem that exposes Kubernetes container filesystems locally.
Browse namespaces, pods, and containers as directories, read files,
and diff configs across pods using standard shell tools.
caveats: |
Requires FUSE:
- Linux: install fuse3
- macOS: install macFUSE (https://github.com/macfuse/macfuse)

Containers must have sh, stat, find, and dd available.

Usage:
kubectl vifal /mnt/my-cluster
ls /mnt/my-cluster/<namespace>/<pod>/<container>/
kubectl vifal unmount /mnt/my-cluster
15 changes: 13 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"k8s.io/client-go/informers"
"k8s.io/client-go/kubernetes"
listerscorev1 "k8s.io/client-go/listers/core/v1"
_ "k8s.io/client-go/plugin/pkg/client/auth"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/util/workqueue"
Expand Down Expand Up @@ -60,6 +61,16 @@ var (
statCmdSuffix = "-maxdepth 1 -exec stat -c '%n\x1d%i\x1d%s\x1d%b\x1d%X\x1d%Y\x1d%Z\x1d%f\x1d%h\x1d%u\x1d%g\x1d%t\x1d%T\x1d%o\x1d%N' {} +"
)

// cmdName returns the user-facing command name: "kubectl vifal" when invoked
// as a kubectl plugin, or the plain binary name otherwise.
func cmdName() string {
bin := filepath.Base(os.Args[0])
if name, ok := strings.CutPrefix(bin, "kubectl-"); ok {
return fmt.Sprintf("kubectl %s", name)
}
return bin
}

func main() {
if len(os.Args) > 1 && os.Args[1] == subcmdUnmount {
cmdUnmount(os.Args[2:])
Expand Down Expand Up @@ -98,7 +109,7 @@ func cmdMount() {
fsName := pflag.String("fsname", defaultFSName, "filesystem name")
cacheTTL := pflag.Duration("attr-ttl", attrTTL, "TTL for attribute and directory caches")

bin := filepath.Base(os.Args[0])
bin := cmdName()
pflag.Usage = func() {
fmt.Fprintf(os.Stderr, `Usage: %[1]s [flags] MOUNTPOINT
%[1]s %[2]s [--rm] [--force] MOUNTPOINT
Expand Down Expand Up @@ -244,7 +255,7 @@ func cmdUnmount(args []string) {
rm := f.Bool("rm", false, "remove the mountpoint directory even if unmount fails")
force := f.Bool("force", false, "force unmount even if busy (lazy unmount)")

bin := filepath.Base(os.Args[0])
bin := cmdName()
f.Usage = func() {
fmt.Fprintf(os.Stderr, `Usage: %[1]s %[2]s [--rm] [--force] MOUNTPOINT

Expand Down
Loading