cloudnativelabs / kube-shell

Kubernetes shell: An integrated shell for working with the Kubernetes
Apache License 2.0
2.38k stars 172 forks source link

describe configmap Exception #35

Closed tedwardd closed 7 years ago

tedwardd commented 7 years ago

Typing the following in the kube-shell followed by a space produces an error (provided at the end of the report)

kubectl describe configmap

kube-shell> kubectl describe configmap Exception in thread Thread-73:
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 810, in __bootstrap_r
    self.run()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 763, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/Users/user/.pyenv/versions/kube-shell/lib/python2.7/site-packages/prompt_toolkit/interface.py", line 860, in n
    completions = list(buffer.completer.get_completions(document, complete_event))
  File "/Users/user/.pyenv/versions/kube-shell/lib/python2.7/site-packages/kubeshell/completer.py", line 246, in get_cs
    resources = self.get_resources(arg, namespace)
  File "/Users/user/.pyenv/versions/kube-shell/lib/python2.7/site-packages/kubeshell/completer.py", line 325, in get_rs
    ret = v1.list_config_map_for_all_namespaces(watch=False)
  File "/Users/user/.pyenv/versions/kube-shell/lib/python2.7/site-packages/kubernetes/client/apis/core_v1_api.py", lins
    (data) = self.list_config_map_for_all_namespaces_with_http_info(**kwargs)
  File "/Users/user/.pyenv/versions/kube-shell/lib/python2.7/site-packages/kubernetes/client/apis/core_v1_api.py", lino
    collection_formats=collection_formats)
  File "/Users/user/.pyenv/versions/kube-shell/lib/python2.7/site-packages/kubernetes/client/api_client.py", line 329,i
    _return_http_data_only, collection_formats, _preload_content, _request_timeout)
  File "/Users/user/.pyenv/versions/kube-shell/lib/python2.7/site-packages/kubernetes/client/api_client.py", line 153,i
    _request_timeout=_request_timeout)
  File "/Users/user/.pyenv/versions/kube-shell/lib/python2.7/site-packages/kubernetes/client/api_client.py", line 361,t
    headers=headers)
  File "/Users/user/.pyenv/versions/kube-shell/lib/python2.7/site-packages/kubernetes/client/rest.py", line 240, in GET
    query_params=query_params)
  File "/Users/user/.pyenv/versions/kube-shell/lib/python2.7/site-packages/kubernetes/client/rest.py", line 217, in ret
    raise ApiException(status=0, reason=msg)
ApiException: (0)
Reason: SSLError
[SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590)
tedwardd commented 7 years ago

Also get the same error with the following:

kubectl --namespace

Any time I invoke the --namespace flag or try to perform and action on the configmap type I receive this error.

murali-reddy commented 7 years ago

client-python library that kube-shell uses seems to be running in to some problem. @k4k Could you please share details of your enviromnent. We had an issue #26 reported with python kubernetes library when running on GKE/AWS.

Also can you please confirm if kubectl works fine?

tedwardd commented 7 years ago

@murali-reddy I can confirm that kubectl works fine. I've been using it now for a few months in our environment and have seen no issues. While I do have a GKE cluster configured in $HOME/.kube/config the error above appears when I have the context for either of our on premises clusters (cluster1.stage or cluster1.prod) active. More details are provided below. If you need something not included, please let me know. I'm happy to provide whatever info is needed, I'm just not sure exactly what is and is not useful for the purposes here.

Client info:

$ kubectl config get-contexts
CURRENT   NAME                                              CLUSTER                                           AUTHINFO                                          NAMESPACE
          cluster1.stage                                    cluster1.stage                                    me@domain.com
          gke_test-server-nnnnnn_us-xxxxx-b_example-cluster   gke_test-server-nnnnnn_us-xxxxx-b_example-cluster   gke_test-server-nnnnnn_us-xxxxx-b_example-cluster
          minikube                                          minikube                                          minikube
*         cluster1.prod                                     cluster1.prod                                     me@domain.com
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"6", GitVersion:"v1.6.4", GitCommit:"d6f433224538d4f9ca2f7ae19b252e6fcb66a3ae", GitTreeState:"clean", BuildDate:"2017-05-19T20:41:07Z", GoVersion:"go1.8.1", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"6", GitVersion:"v1.6.5", GitCommit:"490c6f13df1cb6612e0993c4c14f2ff90f8cdbf3", GitTreeState:"clean", BuildDate:"2017-06-14T20:03:38Z", GoVersion:"go1.7.6", Compiler:"gc", Platform:"linux/amd64"}

Server Info:

$ cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)
$ rpm -q kubernetes
kubernetes-1.6.5-1.x86_64
$ rpm -q docker-engine
docker-engine-1.12.6-1.el7.centos.x86_64
vogxn commented 7 years ago

@k4k I've worked around the client-python errors and fixed it in #26. I would love to know if it fixes your issue. You can still check if it works by installing from my branch as follows

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

If this does fix the issue, I'll put it out in a release soon.

tedwardd commented 7 years ago

@vogxn Different warning now:

kube-shell> kubectl describe configmap/Users/user/.pyenv/versions/3.5.1/envs/kube-shell-testing/lib/python3.5/site-pacs
  InsecureRequestWarning

The full command I was attempting was:

kubectl describe configmap -ncluster

Ultimately, it looks like the commands succeeds but each new keystroke after the space following the configmap noun produces a warning. You can see the beginning of each line contains the next character typed:

kube-shell> kubectl describe configmap /Users/user/.pyenv/versions/3.5.1/envs/kube-shell-testing/lib/python3.5/site-pas
  InsecureRequestWarning)
-/Users/user/.pyenv/versions/3.5.1/envs/kube-shell-testing/lib/python3.5/site-packages/urllib3/connectionpool.py:852: s
  InsecureRequestWarning)
n/Users/user/.pyenv/versions/3.5.1/envs/kube-shell-testing/lib/python3.5/site-packages/urllib3/connectionpool.py:852: s
  InsecureRequestWarning)
c/Users/user/.pyenv/versions/3.5.1/envs/kube-shell-testing/lib/python3.5/site-packages/urllib3/connectionpool.py:852: s
  InsecureRequestWarning)
l/Users/user/.pyenv/versions/3.5.1/envs/kube-shell-testing/lib/python3.5/site-packages/urllib3/connectionpool.py:852: s
  InsecureRequestWarning)
u/Users/user/.pyenv/versions/3.5.1/envs/kube-shell-testing/lib/python3.5/site-packages/urllib3/connectionpool.py:852: s
  InsecureRequestWarning)
/Users/user/.pyenv/versions/3.5.1/envs/kube-shell-testing/lib/python3.5/site-packages/urllib3/connectionpool.py:852: Is
  InsecureRequestWarning)
s/Users/user/.pyenv/versions/3.5.1/envs/kube-shell-testing/lib/python3.5/site-packages/urllib3/connectionpool.py:852: s
  InsecureRequestWarning)
t/Users/user/.pyenv/versions/3.5.1/envs/kube-shell-testing/lib/python3.5/site-packages/urllib3/connectionpool.py:852: s
  InsecureRequestWarning)
er/Users/user/.pyenv/versions/3.5.1/envs/kube-shell-testing/lib/python3.5/site-packages/urllib3/connectionpool.py:852:s
  InsecureRequestWarning)
kube-shell> kubectl describe configmap -ncluster
Name:       cluster-traefik
Namespace:  cluster
Labels:     app=traefik
[...omitted for brevity...]
vogxn commented 7 years ago

This warning will need suppressing. Do you happen to be connecting to a cluster without HTTPS?

On 11 Jul 2017 9:35 p.m., "Ted W." notifications@github.com wrote:

@vogxn https://github.com/vogxn Different error now:

kube-shell> kubectl describe configmap/Users/user/.pyenv/versions/3.5.1/envs/kube-shell-testing/lib/python3.5/site-pacs InsecureRequestWarning

The full command I was attempting was:

kubectl describe configmap -ncluster

Ultimately, it looks like the commands succeeds but each new keystroke after the space following the configmap noun produces a warning. You can see the beginning of each line contains the next character typed:

kube-shell> kubectl describe configmap /Users/user/.pyenv/versions/3.5.1/envs/kube-shell-testing/lib/python3.5/site-pas InsecureRequestWarning) -/Users/user/.pyenv/versions/3.5.1/envs/kube-shell-testing/lib/python3.5/site-packages/urllib3/connectionpool.py:852: s InsecureRequestWarning) n/Users/user/.pyenv/versions/3.5.1/envs/kube-shell-testing/lib/python3.5/site-packages/urllib3/connectionpool.py:852: s InsecureRequestWarning) c/Users/user/.pyenv/versions/3.5.1/envs/kube-shell-testing/lib/python3.5/site-packages/urllib3/connectionpool.py:852: s InsecureRequestWarning) l/Users/user/.pyenv/versions/3.5.1/envs/kube-shell-testing/lib/python3.5/site-packages/urllib3/connectionpool.py:852: s InsecureRequestWarning) u/Users/user/.pyenv/versions/3.5.1/envs/kube-shell-testing/lib/python3.5/site-packages/urllib3/connectionpool.py:852: s InsecureRequestWarning) /Users/user/.pyenv/versions/3.5.1/envs/kube-shell-testing/lib/python3.5/site-packages/urllib3/connectionpool.py:852: Is InsecureRequestWarning) s/Users/user/.pyenv/versions/3.5.1/envs/kube-shell-testing/lib/python3.5/site-packages/urllib3/connectionpool.py:852: s InsecureRequestWarning) t/Users/user/.pyenv/versions/3.5.1/envs/kube-shell-testing/lib/python3.5/site-packages/urllib3/connectionpool.py:852: s InsecureRequestWarning) er/Users/user/.pyenv/versions/3.5.1/envs/kube-shell-testing/lib/python3.5/site-packages/urllib3/connectionpool.py:852:s InsecureRequestWarning) kube-shell> kubectl describe configmap -ncluster Name: cluster-traefik Namespace: cluster Labels: app=traefik [...omitted for brevity...]

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/cloudnativelabs/kube-shell/issues/35#issuecomment-314492278, or mute the thread https://github.com/notifications/unsubscribe-auth/ABNpziJS1BxeBAKnEIFvOqndBT_MqUuJks5sM5zhgaJpZM4OTI-M .

vogxn commented 7 years ago

Ok, I've updated my branch further with a possible fix.

commit 3f3a21626dc807e77b57e9ccd3eae967d650ffbb
Author: Prasanna Santhanam <tsp@apache.org>
Date:   Tue Jul 11 21:44:26 2017 +0530

    fixes #26: disable InsecureRequestWarning from urllib3

diff --git a/kubeshell/client.py b/kubeshell/client.py
index eaf46fb..cb6027d 100644
--- a/kubeshell/client.py
+++ b/kubeshell/client.py
@@ -8,6 +8,7 @@ import urllib3
 # disable warnings on stdout/stderr from urllib3 connection errors
 ulogger = logging.getLogger("urllib3")
 ulogger.setLevel("ERROR")
+urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

 class KubernetesClient(object):
tedwardd commented 7 years ago

@vogxn I'm connecting over HTTPS but I have insecure-skip-tls-verify: true set in $HOME/.kube/config due to our use of a self signed cert for the cluster controllers at this time. This will change in the future as we have plans to put the 5 controller nodes behind a load balancer and use our "real" certificate. Until then I'm connecting directly to node1 in the cluster which has a self signed cert:

clusters:
- cluster:
  insecure-skip-tls-verify: true
  server: https://node1.cluster1.my-domain.com
name: cluster1.prod

I have confirmed that setting urllib3.disable_warnings() as you did suppresses the warning.

vogxn commented 7 years ago

Thanks @k4k - I'm merging my fix to master and will put out a release. Great to have quick feedback and testing :)

vogxn commented 7 years ago

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