Coder Social home page Coder Social logo

kubectl-unused-volumes's Introduction

kubectl-unused-volumes

A kubectl plugin to gather all PVC and output all pvcs that doesn't belong to any workloads. This plugins checks for standard kubernetes workloads :

  • DaemonSet
  • Deployment
  • Job
  • StatefulSet

Quick Start

Install unused-volumes via krew

kubectl krew install unused-volumes

# Scan for all unused volumes in current context and default namespace

kubectl unused-volumes

Demo

Scan Unused pvc on namespace infra

kubectl-unused-volumes's People

Contributors

dirathea avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kubectl-unused-volumes's Issues

panic: runtime error: invalid memory address or nil pointer dereference

Thanks for the tool. It's really cool job.

But on some clusters I get the following error:

$ kubectl unused-volumes


[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xf90404]

goroutine 1 [running]:
github.com/dirathea/kubectl-unused-volumes/pkg/workload.job.IsEmpty(...)
        /Users/aldiraraharja/ssi-gopath-symlink/src/github.com/dirathea/kubectl-unused-volumes/pkg/workload/workload.go:111
github.com/dirathea/kubectl-unused-volumes/pkg/plugin.RunPlugin(0xc0001b3550, 0xc000408700, 0xc0004496d0, 0xc000139d58, 0x10d99f1)
	/Users/aldiraraharja/ssi-gopath-symlink/src/github.com/dirathea/kubectl-unused-volumes/pkg/plugin/plugin.go:65 +0x32c
github.com/dirathea/kubectl-unused-volumes/cmd/plugin/cli.RootCmd.func2(0xc000285180, 0x1eb2c30, 0x0, 0x0, 0x0, 0x0)
	/Users/aldiraraharja/ssi-gopath-symlink/src/github.com/dirathea/kubectl-unused-volumes/cmd/plugin/cli/root.go:30 +0x31
github.com/spf13/cobra.(*Command).execute(0xc000285180, 0xc00003a1d0, 0x0, 0x0, 0xc000285180, 0xc00003a1d0)
	/Users/aldiraraharja/ssi-gopath-symlink/pkg/mod/github.com/spf13/[email protected]/command.go:762 +0x453
github.com/spf13/cobra.(*Command).ExecuteC(0xc000285180, 0x441d1a, 0x1e02040, 0xc00005c778)
	/Users/aldiraraharja/ssi-gopath-symlink/pkg/mod/github.com/spf13/[email protected]/command.go:850 +0x2fb
github.com/spf13/cobra.(*Command).Execute(...)
	/Users/aldiraraharja/ssi-gopath-symlink/pkg/mod/github.com/spf13/[email protected]/command.go:800
github.com/dirathea/kubectl-unused-volumes/cmd/plugin/cli.InitAndExecute()
	/Users/aldiraraharja/ssi-gopath-symlink/src/github.com/dirathea/kubectl-unused-volumes/cmd/plugin/cli/root.go:50 +0x2b
main.main()
	/Users/aldiraraharja/ssi-gopath-symlink/src/github.com/dirathea/kubectl-unused-volumes/cmd/plugin/main.go:12 +0x20```


I noticed this error occurs with some namespaces where are no any pvc/pv(s) , but job/cronjob exist and a lot pods in status `Completed`

Missing "--all-namespaces" flag

The latest version mentions an "all namespaces" option that does not exist.

$ kubectl unused-volumes --help | grep namespaces
        # Get all unused volumes in all namespaces
        kubectl unused-volumes --all-namespaces

$ kubectl unused-volumes --all-namespaces
unknown flag: --all-namespaces

$ kubectl unused-volumes --version
unknown flag: --version

Workaround :

$ for NAMESPACE in $(kubectl get namespaces | awk '{print $1}') ; do echo " --- ${NAMESPACE} ---" ; kubectl unused-volumes --namespace ${NAMESPACE} --no-headers | egrep -v '^$' ; done

Unable to install unused-volumes plugin on mac OS

Tried installing on Apple mac OS platform it reports below error

Installing plugin: unused-volumes
W0509 12:27:52.985878 6678 install.go:164] failed to install plugin "unused-volumes": plugin "unused-volumes" does not offer installation for this platform
failed to install some plugins: [unused-volumes]: plugin "unused-volumes" does not offer installation for this platform

Darwin 00WKSMAC151146.local 21.2.0 Darwin Kernel Version 21.2.0: Sun Nov 28 20:28:41 PST 2021; root:xnu-8019.61.5~1/RELEASE_ARM64_T6000 arm64

Not reliable

This plug-in is not reliable for older Kubernetes versions. When running on 1.11 cluster gives me output all the pvc names although they are bounded with pods

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.