godaddy / kubernetes-client

Simplified Kubernetes API client for Node.js.
MIT License
962 stars 192 forks source link

Confused about deprecation and new backends #566

Open garyo opened 4 years ago

garyo commented 4 years ago

I'm new to this API, trying to use it instead of @kubernetes/client-node because it can read .kube/config and do apply -f.

I'm just trying to instantiate the API with my kube config and use it, but I'm confused about how to avoid the deprecation warnings. The provided apply-deploy example is simple, like this:

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

but that gives the deprecation warnings, either:

deprecated fromKubeconfig see https://github.com/godaddy/kubernetes-client/blob/master/merging-with-kubernetes.md#request-kubeconfig- or deprecated require('kubernetes-client').config, use require('kubernetes-client/backends/request').config.

Do I need to explicitly request one backend or the other?

I've read through https://github.com/godaddy/kubernetes-client/blob/master/merging-with-kubernetes.md#request-kubeconfig- but I don't understand the details of this lib well enough to get it working. Any chance we could get a simple example that doesn't trigger the deprecation warnings? (If there already are some, just point me to them, thanks!)

(Also I'm not getting type hints in my IDE, not sure why.)