astefanutti / kubebox

⎈❏ Terminal and Web console for Kubernetes
http://astefanutti.github.io/kubebox
MIT License
2.15k stars 142 forks source link

Kubebox should simply work the way kubectl works #6

Closed ghost closed 6 years ago

ghost commented 6 years ago

Generally Kubebox should simply work the way kubectl works. I've copied binary to kubernetes master node and ran it from there and it's asking me for credentials while kubectl works fluently. I believe even running kubectl under the hood won't hurt.

astefanutti commented 6 years ago

This should be addressed by f7d1e09b2d42c1ecabe214f13a2a87ed3f1bfd84.

ghost commented 6 years ago

Seems like f7d1e09 addresses running kubebox inside a pod, not in a host node

astefanutti commented 6 years ago

Correct. I need to check how kubectl is dealing connection from host node...

ghost commented 6 years ago

And so it would be possible to run kubebox on every machine that has proper kubectl configuration

astefanutti commented 6 years ago

I guess kubectl relies on the KUBECONFIG environment variable, which Kubebox should support with #9.

astefanutti commented 6 years ago

@k1-hedayati I've just released version 0.2.0 that contains support for the KUBECONFIG environment variable. Would you be able to give it a spin?

ghost commented 6 years ago

Sure, this is the result:

➜  ~ ./kubebox-linux 
fs.js:663
  return binding.open(pathModule.toNamespacedPath(path),
                 ^

Error: ENOENT: no such file or directory, open 'local.crt'
    at Object.fs.openSync (fs.js:663:18)
    at Object.fs.readFileSync (fs.js:568:33)
    at Context.getMasterApi ([eval]:349:21)
    at new Kubebox ([eval]:1145:53)
    at Object.1../lib/kubebox ([eval]:15:1)
    at s ([eval]:1:254)
    at e ([eval]:1:425)
    at [eval]:1:443
    at Script.runInThisContext (vm.js:65:33)
    at Object.runInThisContext (vm.js:199:38)

Kubeconfig:

apiVersion: v1
clusters:
- cluster:
    certificate-authority: local.ca
    server: https://X.X.X.X:6443
  name: local
contexts:
- context:
    cluster: local
    user: kube-local
  name: local
current-context: local
kind: Config
preferences: {}
users:
- name: kube-local
  user:
    client-certificate: local.crt
    client-key: local.key
astefanutti commented 6 years ago

Thanks. Quoting the documentation:

File and path references in a kubeconfig file are relative to the location of the kubeconfig file.

Let me fix that ASAP.

astefanutti commented 6 years ago

@k1-hedayati I've just released version 0.2.1 that should handle relative paths in kubeconfig files (ae8ebb2ecc4b0e8ea9677df87e3ac9202ce54ef9). Let me know how that goes!

ghost commented 6 years ago

Yes it does handle relative paths in kubeconfig files and reads cluster data but seems like there is no option to use another context other that default one

astefanutti commented 6 years ago

Yes it does handle relative paths in kubeconfig files and reads cluster data but seems like there is no option to use another context other that default one

Not sure what you mean exactly.

Interactively, you can press the L key to open the login modal from which you can navigate other contexts and create new ones.

I plan to add an exhaustive CLI with options to resolve the context to use as documented in https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/#merging-kubeconfig-files. Is that what you have in mind?

ghost commented 6 years ago

Pressing L will open login modal as you said but it will not use currently defined contexts in kubeconfig, I want to be able to use other contexts other that default one but now seems like only option to do so is changing default context via kubectl config set-context Yes adding some CLI options for this would be great along with option to change context interactively

astefanutti commented 6 years ago

Pressing L will open login modal as you said but it will not use currently defined contexts in kubeconfig, I want to be able to use other contexts other that default one but now seems like only option to do so is changing default context via kubectl config set-context

From the login modal, you can use the left and right arrows keys to navigate the other defined contexts from kubeconfig files. There is only a subset of fields display currently, so it may not be obvious to choose the context from, but at least you can switch context.

ghost commented 6 years ago

Yes that it correct, you can choose context via arrow keys. So I'm closing this issue, thanks for support

astefanutti commented 6 years ago

I plan to add some sort of UI hints, like context name and position, to the login modal so that it's more explicit user can navigate contexts with arrows.