danielfoehrKn / kubeswitch

The kubectx for operators.
https://danielfoehrkn.medium.com/the-case-of-kubeswitch-aff4b6a04ae7
Apache License 2.0
832 stars 80 forks source link

Option to disable prefix of kubeconfig (filesystem) #19

Closed rbo closed 3 years ago

rbo commented 3 years ago

Follow up to comment https://github.com/danielfoehrKn/kubeswitch/issues/18#issuecomment-842440254

Please provide an option to disable the prefix of kubeconfig:

image

$ cat ~/.kube/config.CLEAN
apiVersion: v1
clusters:
  - cluster:
        insecure-skip-tls-verify: true
        server: https://api.vmw.example.com:6443
    name: api-vmw-example-com:6443
contexts:
  - context:
        cluster: api-vmw-example-com:6443
        namespace: windows-container
        user: kube:admin/api-vmw-example-com:6443
    name: windows-container/api-vmw-example-com:6443/kube:admin
  - context:
        cluster: api-vmw-example-com:6443
        namespace: windows-workload
        user: kube:admin/api-vmw-example-com:6443
    name: windows-workload/api-vmw-example-com:6443/kube:admin
current-context: demo-app/api-demo-openshift-pub:6443/admin
kind: Config
preferences: {}
users:
  - name: kube:admin/api-vmw-example-com:6443
    user:
        token: sha256~A518ZtBiOcuyuYuYWk96-NTgZaJh_vfqomZ-SyXTNpc
$ switch --show-preview=false --kubeconfig-path ~/.kube/config.CLEAN

Thanks Robert

danielfoehrKn commented 3 years ago

Version 0.4.4 with this documentation should do the trick.

Let me know if that works for you. Thanks :)

rbo commented 3 years ago

looks great, one thing I don't get it:

$ switch version
Switch:
        version     : v0.4.4
        build date  : 2021-05-18
        go version  : go1.15.12
        go compiler : gc
        platform    : linux/amd64
$ switch --show-preview=false                              # <= Select one context
/var/home/rbohne/.kube/.switch_tmp/config.152677003.tmp$   # <= It doesn't switch the context it prints the created kubeconfig?
$
danielfoehrKn commented 3 years ago

Did you alias switcher to switch?

Run which switch and it should output a bash script.

Make sure to source the switch.sh script in your bashcr or .zsh according to the installation guide.

danielfoehrKn commented 3 years ago

This document might also be helpful to understand how kubeswitch works.

rbo commented 3 years ago

Ah, got it.

I'm more a friend of curl:

OS=linux                        # Pick the right os: linux, darwin (intel only)
VERSION=0.4.4                   # Pick the current version.

curl -L -o /usr/local/bin/switcher https://github.com/danielfoehrKn/kubeswitch/releases/download/${VERSION}/switcher_${OS}_amd64
chmod +x /usr/local/bin/switcher 

curl -L -o  /usr/local/bin/switch.sh https://github.com/danielfoehrKn/kubeswitch/releases/download/${VERSION}/switch.sh
chmod +x /usr/local/bin/switch.sh

This document might also be helpful to understand how kubeswitch works.

Got it, now I understand how kubeswitch works. To be honest the how it works was not very helpful for me :-(

Just a quick idea:


Kubeswitch is build of two components:

For a proper installation, you have to source the switch.sh source switch.sh and the switcher command have to be available in your $PATH. Because the switch shell function executes the switcher command.


Hope it helps...

Thank you very much, now It works like charm. The copy of the kubeconfig is greater. now I can connect to more than one cluster in different terminals :-)

danielfoehrKn commented 3 years ago

Thanks for the proposal, I will add it to the document!

I guess we can close this issue now that it works for you.

danielfoehrKn commented 3 years ago

I updated the READ.ME and docs.