Git Product home page Git Product logo

kubeconfig-cleanup's Introduction

kubeconfig-cleanup

About

Description

A kubectl plugin to clean up your kubeconfig file

Installation

Add kubeconfig-cleanup to your kubectl plugins directory. For more information about how plugins are loaded, please see the official documentation.

See Releases for the latest release matching your OS.

# Pick the right release, e.g. "v1.0.1 Linux x64"
$ export BINARY=kubeconfig-cleanup_1.0.1_Linux_x86_64.tar.gz

Then run install.sh by either cloning this repository or directly downloading the script.

Note: The script and plugin configuration is configured to use ~/.kube/plugins/kubeconfig-cleanup as the plugin and installation folder.

$ git clone https://github.com/ashleyschuett/kubeconfig-cleanup
$ cd kubeconfig-cleanup

# make sure the script it's executable
$ chmod +x install.sh
$ ./install.sh

Alternatively with curl:

$ curl -LO https://raw.githubusercontent.com/ashleyschuett/kubeconfig-cleanup/master/install.sh

# make sure the script it's executable
$ chmod +x install.sh
$ ./install.sh

Usage

Parse through kubeconfig in default directory

kubectl plugin kubeconfig-cleanup

Parse through kubeconfig at custom location

kubectl plugin kubeconfig-cleanup --kubeconfig /custom/kubeconfig/location

kubeconfig-cleanup's People

Contributors

embano1 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

kubeconfig-cleanup's Issues

Error on Ubuntu 16.04

I just discovered this project and am keen to give it a try. I followed the instructions in the README to clone the repo into the .kube/plugins/kubeconfig-cleanup folder but I get the following error when I try to run it:

 $ kubectl plugin kubeconfig-cleanup
error: fork/exec ./cleanup: exec format error

I also tried to grab the source with go get but get an error with that too:

# github.com/ashleyschuett/kubeconfig-cleanup/pkg/config
pkg/config/config.go:164:52: cannot use m.getContextsUser(context) (type *"k8s.io/client-go/tools/clientcmd/api".AuthInfo) as type *"k8s.io/kubernetes/vendor/k8s.io/client-go/tools/clientcmd/api".AuthInfo in assignment
pkg/config/config.go:166:118: cannot use "k8s.io/apimachinery/pkg/apis/meta/v1".GetOptions literal (type "k8s.io/apimachinery/pkg/apis/meta/v1".GetOptions) as type "k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/apis/meta/v1".GetOptions in argument to client.CoreV1().ConfigMaps("k8s.io/apimachinery/pkg/apis/meta/v1".NamespacePublic).Get

Any suggestions? :-)

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

Hi,

Getting a panic directly after involvement.

$ k plugin kubeconfig-cleanup
[kubeconfig] Using default path '$HOME/.kube/config'

| panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x80 pc=0x19a6603]

goroutine 23 [running]:
github.com/ashleyschuett/kubeconfig-cleanup/vendor/k8s.io/client-go/kubernetes.(*Clientset).CoreV1(...)
        /Users/ashley/go/src/github.com/ashleyschuett/kubeconfig-cleanup/vendor/k8s.io/client-go/kubernetes/clientset.go:273
github.com/ashleyschuett/kubeconfig-cleanup/pkg/config.(*Manager).Validate(0xc420312940, 0xc42028f2c0, 0x0, 0x0, 0x0)
        /Users/ashley/go/src/github.com/ashleyschuett/kubeconfig-cleanup/pkg/config/config.go:164 +0x1a3
github.com/ashleyschuett/kubeconfig-cleanup/pkg/config.(*Manager).ValidateAndAddToWorkqueue(0xc420312940, 0xc4202befc0, 0x15, 0xc42028f2c0)
        /Users/ashley/go/src/github.com/ashleyschuett/kubeconfig-cleanup/pkg/config/workqueue.go:26 +0x3c
created by github.com/ashleyschuett/kubeconfig-cleanup/pkg/config.(*Manager).Run
        /Users/ashley/go/src/github.com/ashleyschuett/kubeconfig-cleanup/pkg/config/config.go:64 +0xc1
error: exit status 2

New Installation breaks tool

Hi Ashley,

Thx for switching to goreleaser :)

I found some issues with the new installation procedure:

export BINARY=kubeconfig-cleanup_1.0.1_Linux_x86_64.tar.gz
curl -LO -o cleanup https://github.com/ashleyschuett/kubeconfig-cleanup/releases/download/v1.0.1/$BINARY && \
curl -LO https://raw.githubusercontent.com/ashleyschuett/kubeconfig-cleanup/v1.0.1/plugin.yaml && \
mkdir ~/.kube/plugins/kubeconfig-cleanup && mv cleanup plugin.yaml
  1. The BINARY is a tgz, meaning that it must be extracted first and not just moved (will error out with error: fork/exec ./cleanup: exec format error)
  2. The binary then has to be executable (chmod +x), otherwise error: fork/exec ./cleanup: permission denied
  3. curl -LO -o does not work because -o has no effect here (just remove -O to fix)
  4. mkdir should use option -p to not error out when plugins does not exist or when kubeconfig-cleanup already exists (e.g. upgrade)
  5. the mv needs a target folder, i.e. mv cleanup plugin.yaml ~/.kube/plugins/kubeconfig-cleanup

Will file PR :)

Doesn't work with GCP auth provider (GKE contexts)

I get this when trying to run:

Testing context's 'gke-skeenan-eaa3d8e68f' cluster...
error converting to clientset: failed to create API client: No Auth Provider found for name "gcp"
Remove 'gke-skeenan-eaa3d8e68f' from context (Y/n)? panic: reflect: call of reflect.Value.Type on zero Value

goroutine 75 [running]:
reflect.Value.Type(0x0, 0x0, 0x0, 0x1c81aa0, 0x1b5d640)
	/usr/local/Cellar/go/1.10.3/libexec/src/reflect/value.go:1713 +0x16d
github.com/ashleyschuett/kubeconfig-cleanup/vendor/github.com/imdario/mergo.Merge(0x1a85600, 0xc4203ec000, 0x1a85600, 0x0, 0xc42039c498, 0xc420396301)
	/Users/ashley/go/src/github.com/ashleyschuett/kubeconfig-cleanup/vendor/github.com/imdario/mergo/merge.go:95 +0x114
github.com/ashleyschuett/kubeconfig-cleanup/vendor/k8s.io/client-go/tools/clientcmd.(*DirectClientConfig).getAuthInfo(0xc4203b2000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/Users/ashley/go/src/github.com/ashleyschuett/kubeconfig-cleanup/vendor/k8s.io/client-go/tools/clientcmd/client_config.go:423 +0x2df
github.com/ashleyschuett/kubeconfig-cleanup/vendor/k8s.io/client-go/tools/clientcmd.(*DirectClientConfig).ClientConfig(0xc4203b2000, 0x0, 0x0, 0x0)
	/Users/ashley/go/src/github.com/ashleyschuett/kubeconfig-cleanup/vendor/k8s.io/client-go/tools/clientcmd/client_config.go:113 +0x71
github.com/ashleyschuett/kubeconfig-cleanup/vendor/k8s.io/kubernetes/cmd/kubeadm/app/util/kubeconfig.ToClientSet(0xc4203991a0, 0xc42039a6f0, 0x0, 0x0)
	/Users/ashley/go/src/github.com/ashleyschuett/kubeconfig-cleanup/vendor/k8s.io/kubernetes/cmd/kubeadm/app/util/kubeconfig/kubeconfig.go:80 +0x80
github.com/ashleyschuett/kubeconfig-cleanup/pkg/config.(*Manager).Validate(0xc4201ed500, 0xc42016c960, 0x0, 0x0, 0x0)
	/Users/ashley/go/src/github.com/ashleyschuett/kubeconfig-cleanup/pkg/config/config.go:163 +0x195
github.com/ashleyschuett/kubeconfig-cleanup/pkg/config.(*Manager).ValidateAndAddToWorkqueue(0xc4201ed500, 0xc42033e5b0, 0x7, 0xc42016c960)
	/Users/ashley/go/src/github.com/ashleyschuett/kubeconfig-cleanup/pkg/config/workqueue.go:26 +0x3c
created by github.com/ashleyschuett/kubeconfig-cleanup/pkg/config.(*Manager).Run
	/Users/ashley/go/src/github.com/ashleyschuett/kubeconfig-cleanup/pkg/config/config.go:64 +0xc1

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.