且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用 REST API 访问 Kubernetes API

更新时间:2023-01-23 13:41:30

我认为你可以使用这个 kubernetes-clientGoDaddy 推广.Kubernetes-client for NodeJS 简化了如何调整 Kubernetes API 接口的方法.

I think that you can invoke Kubernetes API from NodeJS using this kubernetes-client promoted by GoDaddy. Kubernetes-client for NodeJS simplifies a way how to adjust an interface to Kubernetes API.

下面的示例演示了如何使用一个小片段来提取默认 Kubernetes Namespace 中的所有 Deployments:

Below example demonstrates a way how to use a small snippet to extract all the Deployments in the default Kubernetes Namespace:

const Client = require('kubernetes-client').Client;
const config = require('kubernetes-client').config;

const client = new Client({ config: config.fromKubeconfig(), version: '1.9' });
const deployments = await client.api.v1.namespaces('default').deployments.get();

此处您可以找到更多使用 的代码片段kubernetes-client.

Here you can find more snippets for using kubernetes-client.