Coder Social home page Coder Social logo

kubectl get <object> <space> throws exception about kube-shell HOT 14 CLOSED

bobhenkel avatar bobhenkel commented on May 28, 2024
kubectl get throws exception

from kube-shell.

Comments (14)

murali-reddy avatar murali-reddy commented on May 28, 2024

Kubectl uses go client to talk to api server. Kube-shell uses client-python to talk to api server for resource auto completion. there seems to some problem python api client accessing api server.

Could you please try below snippet from your python interactive shell and see if this goes through?

from kubernetes import client, config
config.load_kube_config()
v1 = client.CoreV1Api()
v1.list_pod_for_all_namespaces(watch=False)

from kube-shell.

bobhenkel avatar bobhenkel commented on May 28, 2024

Still throws an error.

> python                                                                                                                            13:10:54
Python 2.7.13 (default, Dec 18 2016, 07:03:39)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from kubernetes import client, config
>>> config.load_kube_config()
>>> v1 = client.CoreV1Api()
>>> v1.list_pod_for_all_namespaces(watch=False)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/kubernetes/client/apis/core_v1_api.py", line 13650, in list_pod_for_all_namespaces
    (data) = self.list_pod_for_all_namespaces_with_http_info(**kwargs)
  File "/usr/local/lib/python2.7/site-packages/kubernetes/client/apis/core_v1_api.py", line 13743, in list_pod_for_all_namespaces_with_http_info
    collection_formats=collection_formats)
  File "/usr/local/lib/python2.7/site-packages/kubernetes/client/api_client.py", line 329, in call_api
    _return_http_data_only, collection_formats, _preload_content, _request_timeout)
  File "/usr/local/lib/python2.7/site-packages/kubernetes/client/api_client.py", line 153, in __call_api
    _request_timeout=_request_timeout)
  File "/usr/local/lib/python2.7/site-packages/kubernetes/client/api_client.py", line 361, in request
    headers=headers)
  File "/usr/local/lib/python2.7/site-packages/kubernetes/client/rest.py", line 240, in GET
    query_params=query_params)
  File "/usr/local/lib/python2.7/site-packages/kubernetes/client/rest.py", line 231, in request
    raise ApiException(http_resp=r)
kubernetes.client.rest.ApiException: (401)
Reason: Unauthorized
HTTP response headers: HTTPHeaderDict({'Date': 'Wed, 05 Jul 2017 18:18:49 GMT', 'Content-Length': '13', 'Content-Type': 'text/plain; charset=utf-8', 'X-Content-Type-Options': 'nosniff'})
HTTP response body: Unauthorized


>>>

from kube-shell.

mbohlool avatar mbohlool commented on May 28, 2024

Can you share details of your cluster? (Is it on gke or gce or minikube).

from kube-shell.

bobhenkel avatar bobhenkel commented on May 28, 2024

It's a CoreOS Tectonic cluster on AWS. RBAC is enabled.

from kube-shell.

bobhenkel avatar bobhenkel commented on May 28, 2024

Also I'm just using static users at the moment, if that's of any value to the error.

https://coreos.com/tectonic/docs/latest/admin/user-management.html

from kube-shell.

clmssz avatar clmssz commented on May 28, 2024

Same problem here with GKE

from kube-shell.

vogxn avatar vogxn commented on May 28, 2024

The authentication problems are described in a bug within client-python here. The workaround provided is to use service accounts.

I'll dig through the client-python code a little today.

Before I make a change to the code, @clmssz are you using GKE with service accounts?

In the short term I propose to handle kube-apiserver endpoint errors like this without disabling the shell's utility.

from kube-shell.

clmssz avatar clmssz commented on May 28, 2024

@vogxn kubectl uses your gcloud compute credentials I think

from kube-shell.

vogxn avatar vogxn commented on May 28, 2024

I've redirected the errors to an error log. Kubeshell will not dump stacktraces like this now. The pull request is here

You can test this by installing from the branch

$ pip install -e git://github.com/vogxn/kube-shell.git@26-handle-client-python-errors#egg=kube-shell

from kube-shell.

vogxn avatar vogxn commented on May 28, 2024

This is now merged and will be part of the next release along with other bugfixes.

from kube-shell.

vogxn avatar vogxn commented on May 28, 2024

A new release is pushed to pypi with version 0.0.21. An upgrade should fix this issue

from kube-shell.

clmssz avatar clmssz commented on May 28, 2024

Hi @vogxn , no more stacktrace thanks (but no completion, guess it'a what you wanted in the short term right ?)

from kube-shell.

mbohlool avatar mbohlool commented on May 28, 2024

Kubernetes python client 3.0.0b1 should have a fix for this. Can you guys give it a try and let me know if it fixed your problem?

from kube-shell.

pilsy avatar pilsy commented on May 28, 2024

Any progress on this? the auto completion is what made we want to use it

from kube-shell.

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.