在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:kubernetes-client/javascript开源软件地址:https://github.com/kubernetes-client/javascript开源编程语言:TypeScript 99.9%开源软件介绍:Javascript Kubernetes Client informationThe Javascript clients for Kubernetes is implemented in typescript, but can be called from either Javascript or Typescript. The client is implemented for server-side use with Node. The Installationnpm install @kubernetes/client-node Example codeList all podsconst k8s = require('@kubernetes/client-node');
const kc = new k8s.KubeConfig();
kc.loadFromDefault();
const k8sApi = kc.makeApiClient(k8s.CoreV1Api);
k8sApi.listNamespacedPod('default').then((res) => {
console.log(res.body);
}); Create a new namespaceconst k8s = require('@kubernetes/client-node');
const kc = new k8s.KubeConfig();
kc.loadFromDefault();
const k8sApi = kc.makeApiClient(k8s.CoreV1Api);
var namespace = {
metadata: {
name: 'test',
},
};
k8sApi.createNamespace(namespace).then(
(response) => {
console.log('Created namespace');
console.log(response);
k8sApi.readNamespace(namespace.metadata.name).then((response) => {
console.log(response);
k8sApi.deleteNamespace(namespace.metadata.name, {} /* delete options */);
});
},
(err) => {
console.log('Error!: ' + err);
},
); Create a cluster configuration programaticallyconst k8s = require('@kubernetes/client-node');
const cluster = {
name: 'my-server',
server: 'http://server.com',
};
const user = {
name: 'my-user',
password: 'some-password',
};
const context = {
name: 'my-context',
user: user.name,
cluster: cluster.name,
};
const kc = new k8s.KubeConfig();
kc.loadFromOptions({
clusters: [cluster],
users: [user],
contexts: [context],
currentContext: context.name,
});
const k8sApi = kc.makeApiClient(k8s.CoreV1Api);
... Additional Examples and DocumentationThere are several more JS and TS examples in the examples directory. Documentation for the library is split into two resources:
CompatibilityPrior to the Generally speaking newer clients will work with older Kubernetes, but compatability isn't 100% guaranteed.
Key:
Known Issues
DevelopmentAll dependencies of this project are expressed in its
npm install (re) Generating codenpm run generate DocumentationDocumentation is generated via typedoc:
To view the generated documentation, open FormattingRun LintingRun TestingTests are written using the Chai library. See
To run tests, execute the following: npm test ContributingPlease see CONTRIBUTING.md for instructions on how to contribute. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论