godaddy / godaddy/kubernetes-client

Using kubernetes-client with doctl/ DO kubernetes cluster

Open
#504 0 comments 2 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
963
Forks
189
PR merge metrics
No merged PRs in 30d

Description

I am testing kubernetes-agent in my nodejs api endpoint. I followed the following initialisation logic for client to connect to my Digitalocean kubernetes cluster:

```
const Client = require('kubernetes-client').Client
const config = require('kubernetes-client').config
const client = new Client({ config: config.fromKubeconfig(), version: '1.13' });
```

My kubeconfig file is as follows:

```
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: XXXXXXXXX
server: https://f30167ssd-bbvf-4fty-bdff-c44c84baf2ss.k8s.ondigitalocean.com
name: do-test-cluster
contexts:
- context:
cluster: do-test-cluster
user: do-test-cluster-admin
name: do-test-cluster
current-context: do-test-cluster
kind: Config
preferences: {}
users:
- name: do-test-cluster-admin
user:
exec:
apiVersion: client.authentication.k8s.io/v1beta1
args:
- kubernetes
- cluster
- kubeconfig
- exec-credential
- --version=v1beta1
- xxddddrrrrr
command: doctl
env: null
```

I am getting error as follows:

```
(node:5381) UnhandledPromiseRejectionWarning: Error: no auth mechanism defined
at Auth.onRequest (/Users/tapan//nodejs-sample-app/node-js-sample/node_modules/request/lib/auth.js:132:32)
at Request.auth (/Users/tapan//nodejs-sample-app/node-js-sample/node_modules/request/request.js:1347:14)
at Request.init (/Users/tapan//nodejs-sample-app/node-js-sample/node_modules/request/request.js:378:10)
at new Request (/Users/tapan//nodejs-sample-app/node-js-sample/node_modules/request/request.js:127:8)
at request (/Users/tapan//nodejs-sample-app/node-js-sample/node_modules/request/index.js:53:10)
at refreshAuth.then.newAuth (/Users/tapan//nodejs-sample-app/node-js-sample/node_modules/kubernetes-client/backends/request/client.js:142:20)
at
at process._tickCallback (internal/process/next_tick.js:188:7)
(node:5381) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:5381) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
```

The same client works when I supply a different k8s context, which has a bearer-token already available in the kubeconfig file (instead of using doctl to obtain it). doctl is installed on my system, but I am still getting this error. Any inputs on probable solutions are appreciated.

Contributor guide

Open the contributing guide

Research direction

Start with config.fromKubeconfig() and the request path at node_modules/kubernetes-client/backends/request/client.js:142, then compare the working bearer-token context with the doctl exec-based kubeconfig. Reproduce the request against the DigitalOcean cluster and determine whether exec credentials are supported; done means the reported authentication error is resolved without breaking bearer-token contexts.

Written by the indexing model from the issue text.

Assessment

Tech stack
kubernetes, node.js
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.