GithubHelp home page GithubHelp logo

Comments (9)

ahmetb avatar ahmetb commented on May 14, 2024 1

@jwhitcraft I just hacked a kubens tool. Can you try check out this branch, add it to your PATH and try kubens? https://github.com/ahmetb/kubectx/tree/wip-kubens I appreciate feedback.

from kubectx.

ahmetb avatar ahmetb commented on May 14, 2024

@jwhitcraft Interesting idea. I don’t have a lot of daily experience with namespaces. It looks like if you want to associate a namespace with a context entry, you need to create a new context entry (or modify the existing context entry).

Please correct me if I'm wrong, but in your example, my-cluster would always be associated with the test-namespace. I can think of refactoring the kubectx alias functionality to accept a namespace argument like this:

kubectx prod=my-cluster
kubectx test=my-cluster:test-namespace

because there's no way to do kubectl config use-namespace today. What do you think of this?

from kubectx.

jwhitcraft avatar jwhitcraft commented on May 14, 2024

@ahmetb, that works for me. Currently I do this in my bash script which allows me to keep the same context but change the active namespace at will.

function k8sns() {
    ctx=`kubectl config current-context`
    ns=$1

    // verify that the namespace exists
    ns=`kubectl get namespace $1 --no-headers --output=go-template={{.metadata.name}} 2>/dev/null`

    if [ -z "${ns}" ]; then
        echo "Namespace (${1}) not found, using default"
        ns="default"
    fi

    kubectl config set-context ${ctx} --namespace="${ns}"
}

from kubectx.

ahmetb avatar ahmetb commented on May 14, 2024

@jwhitcraft I see, that's essentially modifying your context. But it should be fine. I have an alternative proposal:

We can ship an additional kubens script, just like kubectx it can list/auto-complete the namespaces active in the current context and modify the current context to use the namespace, like your script does. It would also provide switching back and forth between namespaces using kubens –.

Which solution do you like better, a separate tool, or aliasing feature charged with namespaces?

from kubectx.

jwhitcraft avatar jwhitcraft commented on May 14, 2024

@ahmetb a seperate tool would be best the more and more i think about it.

from kubectx.

jwhitcraft avatar jwhitcraft commented on May 14, 2024

@ahmetb I just got back to work and i'll get this setup today.

Thanks!

from kubectx.

ahmetb avatar ahmetb commented on May 14, 2024

@jwhitcraft have you got any feedback?

from kubectx.

jwhitcraft avatar jwhitcraft commented on May 14, 2024

@ahmetb, so far working well. nice job πŸ‘

from kubectx.

ahmetb avatar ahmetb commented on May 14, 2024

This can now be installed brew update && brew install kubectx --HEAD

from kubectx.

Related Issues (20)

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.