Skip to content

Latest commit

 

History

History
106 lines (78 loc) · 3.53 KB

merging-with-kubernetes.md

File metadata and controls

106 lines (78 loc) · 3.53 KB

Merging with @kubernetes/client-node

kubernetes-client is merging with @kubernetes/client-node. kubernetes-client will continue to be a "fluent" JavaScript bindings for the Kubernetes API and @kubernetes/client-node will be a lower-level set of API bindings. As part of this merging process kubernetes-client will adopt some of the @kubernetes/client-node APIs. Those changes, unfortunately, will cause breaking changes to the kubernetes-client API. These breaking changes will be included in [email protected].

See Issue #234 and Pull Request #244 for more discussion.

Preparing to upgrade to 9.0.0

Client({ config })

You must construct your backend of choice with the config options.

// Depcrecated
const client = new Client({ config: config.fromKubeconfig(), version: '1.14' })

// New version
const client = new Client({ version: '1.14' })

// Depcrecated
const config = { /* custom config */ }
const client = new Client({ config, version: '1.14' })

// New version
const config = { /* custom config */ }
const Request = require('kubernetes-client/backends/request')
const client = new Client({ backend: new Request(config), version: '1.14' })

require('kubernetes-client').config

You must access .config via the request backend.

// Depcrecated
const config = require('kubernetes-client').config

// New version
const config = require('kubernetes-client/backends/request').config

.getStream()

You can stream watch endpoints and Pod logs:

// Depcrecated `watch`
const events = client.api.v1.watch.namespaces(namespace).pods.getStream()

// New version `watch` (notice the `await`!)
const events = await client.api.v1.watch.namespaces(namespace).pods.getObjectStream()

// Deprecated `Pod` logs
const stream = client.api.v1.namespaces(namespace).pods(manifest.metadata.name).log.getStream()

// new version `Pod` logs (notice the `await`!)
const stream = await client.api.v1.namespaces(namespace).pods(manifest.metadata.name).log.getByteStream()

We are going to remove support for streaming other endpoints.

Request({ kubeconfig })

You must construct a Request backend with a @kubernetes/client-node KubeConfig object.

// Deprecated loading from kubeconfig file
const Request = require('kubernetes-client/backends/request')
const requestOptions = Request.config.fromKubeconfig(Request.config.loadKubeconfig())
const backend = new Request(requestOptions)

// New version of loading from kubeconfig file
const { KubeConfig } = require('kubernetes-client')
const kubeconfig = new KubeConfig()
kubeconfig.loadFromDefault()
const backend = new Request({ kubeconfig })

// Deprecated loading from in-cluster config
const requestOptions = Request.config.fromKubeconfig(Request.config.getInCluster())
const backend = new Request(requestOptions)

// New reversion of loading from in-cluster config
const kubeconfig = new KubeConfig()
kubeconfig.loadFromCluster()
const backend = new Request({ kubeconfig })

Why are you doing this?

Because it will improve the quality of both JavaScript clients and reduce the engineering effort required to improve and maintain them. For example, instead of maintaining multiple implementations of configuration handling, the community can focus on improving a single implementation.