Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP 401 : Unauthorized at any request while using the conf file #108

Open
tikolsky opened this issue Sep 20, 2017 · 2 comments
Open

HTTP 401 : Unauthorized at any request while using the conf file #108

tikolsky opened this issue Sep 20, 2017 · 2 comments
Assignees

Comments

@tikolsky
Copy link

I am taking the k8s master conf file from /etc/kubernetes/admin.conf and using it as follows:

cfg_other = K8sConfig(kubeconfig='/Path/on/my/laptop')
pod = K8sPod(config=cfg_other, name='postgresql')
pod.list()

Exception:

---------------------------------------------------------------------------
UnauthorizedException                     Traceback (most recent call last)
<ipython-input-32-97bec4cd2ba1> in <module>()
----> 1 pod.list()

/workspace/ubiq/kubernetes-py/kubernetes/K8sPod.pyc in list(self, pattern)
     48
     49     def list(self, pattern=None):
---> 50         ls = super(K8sPod, self).list()
     51         pods = list(map(lambda pod: Pod(pod), ls))
     52         if pattern is not None:

/workspace/ubiq/kubernetes-py/kubernetes/K8sObject.pyc in list(self)
    257     def list(self):
    258         import pdb;pdb.set_trace()
--> 259         state = self.request(method='GET')
    260         if not state.get('status'):
    261             raise Exception('K8sObject: Could not fetch list of objects of type: [ {0} ]'.format(self.obj_type))

UnauthorizedException: K8sObject: LIST failed : HTTP 401 : Unauthorized

This is what the conf file looks like:

apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUN5RENDQWJDZ0F3SUJBZ0lCQURBTkJna3Foa2lHOXcwQkFRc0ZBREFWTVJNd0VRWURWUVFERXdwcmRXSmwKY201bGRHVnpNQjRYRFRFM01EZ3dPVEE1TURZME0xb1hEVEkzTURnd056QTVNRFkwTTFvd0ZURVRNQkVHQTFVRQpBeE1LYTNWaVpYSnVaWFJsY3pDQ0FTSXdEUVlKS29aSWh2Y05BUUVCQlFBR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orbz0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=
    server: https://****:6443
  name: kubernetes
contexts:
- context:
    cluster: kubernetes
    user: admin
  name: admin@kubernetes
- context:
    cluster: kubernetes
    user: kubelet
  name: kubelet@kubernetes
current-context: admin@kubernetes
kind: Config
preferences: {}
users:
- name: admin
  user:
    client-certificate-data: *****
    client-key-data: *****
- name: kubelet
  user:
    client-certificate-data: *****
@

(I replaced IP and certs with ****)

@sebastienc sebastienc self-assigned this Dec 20, 2017
@smiller171
Copy link

I'm getting 403 forbidden doing the same trying to list a service

@sebastienc
Copy link
Contributor

Is this still an issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants