Coder Social home page Coder Social logo

go-kubectx's Introduction

Archived

kubectx is now written in go. Check #12. This project is not maintained anymore.


go-kubectx

Simply 5x-10x faster alternative to famous kubectx. Uses client-go.

Dependencies

Requires fzf same as original kubectx.

Install

Using go mod, requires go>=1.13

git clone [email protected]:aca/go-kubectx.git && cd go-kubectx
go install ./cmd/kubens
go install ./cmd/kubectx

# Using Docker - also cross-compiles for other OS's
# Binaries will be built into the output directory after build.
cd go-kubectx && ./build.sh

or download pre-built binaries from Releases.

Benchmarks

Command Mean [ms] Min [ms] Max [ms] Relative
/usr/bin/kubectx minikube 98.9 ± 12.1 84.8 138.6 5.35 ± 0.89
/home/rok/bin/kubectx minikube 18.5 ± 2.1 15.6 27.1 1.00
Command Mean [ms] Min [ms] Max [ms] Relative
/usr/bin/kubens kube-system 258.6 ± 20.7 237.9 300.9 5.73 ± 1.78
/home/rok/bin/kubens kube-system 45.1 ± 13.6 32.3 120.0 1.00

go-kubectx's People

Contributors

aca avatar dev25 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  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  avatar

Forkers

dev25 slimm609 stamm

go-kubectx's Issues

fzf not found

Err: exec: "fzf": executable file not found in $PATH

kubens displays list on direct match

regular kubens changes namespace when given a name as input

kubens valid-ns
Active namespace is "valid-ns".

kubens abc
error: no namespace exists with name "abc".

your kubens displays the list with that as a search field.

most of the time, the namespace is known and just want to switch between them quickly

Cool project!

I've been planning to rewrite it in Go for a long time but never got to it.
If this experiment works out, I might finally go do it just so you know. :)

kubectx times out

When switching to a context for an Amazon EKS cluster that requires mfa authorization, I get the following:

Switched to context "hse"
Enter MFA code for arn:aws:iam::<snip>:mfa/<snip>: W0127 10:56:26.501431    3634 transport.go:243] Unable to cancel request for *exec.roundTripper
<paste token here>

Err: Get https://<snip-hostname>.eks.amazonaws.com/api/v1/namespaces: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

When I re-run the command, it works, as the mfa token has been set correctly.

I would expect the client to wait until the mfa token was entered before attempting any further communication. However, I'm not sure how much you can change here, as it might be upstream in the aws client.

Error when use auth provider

I use auth provider to get token. And sometimes I got an error, when I need to refresh token
kubens test

kgpanic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x1d0c5fb]

goroutine 1 [running]:
k8s.io/client-go/plugin/pkg/client/auth/oidc.(*oidcAuthProvider).idToken(0xc000395d40, 0x0, 0x0, 0x0, 0x0)
        /home/rok/pkg/mod/k8s.io/[email protected]/plugin/pkg/client/auth/oidc/oidc.go:282 +0x6fb
k8s.io/client-go/plugin/pkg/client/auth/oidc.(*roundTripper).RoundTrip(0xc0003c4be0, 0xc000374400, 0x1fab4d7, 0xa, 0xc0003e2620)
        /home/rok/pkg/mod/k8s.io/[email protected]/plugin/pkg/client/auth/oidc/oidc.go:200 +0x7c
k8s.io/client-go/transport.(*userAgentRoundTripper).RoundTrip(0xc0003c4c00, 0xc000374300, 0xc0003c4c00, 0xbf866caaada48648, 0x12db73060)
        /home/rok/pkg/mod/k8s.io/[email protected]/transport/round_trippers.go:159 +0x1c0
net/http.send(0xc000374200, 0x2146e60, 0xc0003c4c00, 0xbf866caaada48648, 0x12db73060, 0x2a9ad80, 0xc00013c5b0, 0xbf866caaada48648, 0x1, 0x0)
        /home/rok/.asdf/installs/golang/1.13.2/go/src/net/http/client.go:250 +0x43a
net/http.(*Client).send(0xc0003b2840, 0xc000374200, 0xbf866caaada48648, 0x12db73060, 0x2a9ad80, 0xc00013c5b0, 0x0, 0x1, 0x0)
        /home/rok/.asdf/installs/golang/1.13.2/go/src/net/http/client.go:174 +0xfa
net/http.(*Client).do(0xc0003b2840, 0xc000374200, 0x0, 0x0, 0x0)
        /home/rok/.asdf/installs/golang/1.13.2/go/src/net/http/client.go:641 +0x3ce
net/http.(*Client).Do(...)
        /home/rok/.asdf/installs/golang/1.13.2/go/src/net/http/client.go:509
k8s.io/client-go/rest.(*Request).request(0xc0003765a0, 0xc0001099b0, 0x0, 0x0)
        /home/rok/pkg/mod/k8s.io/[email protected]/rest/request.go:801 +0x3e9
k8s.io/client-go/rest.(*Request).Do(0xc0003765a0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        /home/rok/pkg/mod/k8s.io/[email protected]/rest/request.go:878 +0xd8
k8s.io/client-go/kubernetes/typed/core/v1.(*namespaces).List(0xc00039bd50, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        /home/rok/pkg/mod/k8s.io/[email protected]/kubernetes/typed/core/v1/namespace.go:86 +0x179
main.kubens(0x7ffeefbff8e7, 0x3, 0x4ca8, 0xc00013e060)
        /home/rok/src/github.com/aca/go-kubectx/cmd/kubens/main.go:96 +0xfc
main.main()
        /home/rok/src/github.com/aca/go-kubectx/cmd/kubens/main.go:77 +0x406

fzf should be optional

In original kubectx/kubens, fzf is optional and fuzzy searching features only activates if fzf is found on the path.
Having the same behavior in go-kubectx will ease switching to your implementation.

Corruption of config files (all field are set to null)

When using multiple config file (by using a KUBECONFIG env var containing multiple paths separated by ":") and launching kubectx, all the files not already in used are modified with all the field set to null.

apiVersion: v1
clusters: null
contexts: null
current-context: delivery
kind: Config
preferences: {}
users: null

The documentation about contiguring the KUBECONFIG env variable:
https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/#set-the-kubeconfig-environment-variable

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.