我使用AKS(Azure k8),需要k8s node.js客户端来选择这个选项
用名字杀死荚
更改部署吊舱数
重新启动所有部署吊舱
我只需要这个函数,女巫库是最好的吗?
还请为其中一些函数提供使用lib的示例。
谢谢
更新
我喜欢这个Node.js (TypeScript) github.com/Goyoo/node-k8s-client,你能提供更多关于服务帐户和访问的信息吗?
发布于 2018-10-22 14:18:06
以下是所有客户端库的完整列表。
https://kubernetes.io/docs/reference/using-api/client-libraries/
您将需要创建服务帐户和角色绑定,以配置从客户端库执行这些操作的适当权限。
node.js专用库:
Node.js (TypeScript) github.com/Goyoo/node-k8s-client Node.js github.com/tenxcloud/节点-kubernetes-client Node.js github.com/godaddy/kubernetes-client
基本示例(使用godaddy )
/* eslint no-console:0 */
//
// Demonstrate some of the basics.
//
const Client = require('kubernetes-client').Client;
const config = require('kubernetes-client').config;
const deploymentManifest = require('./nginx-deployment.json');
async function main() {
try {
const client = new Client({ config: config.fromKubeconfig(), version: '1.9' });
//
// Get all the Namespaces.
//
const namespaces = await client.api.v1.namespaces.get();
console.log('Namespaces: ', namespaces);
//
// Create a new Deployment.
//
const create = await client.apis.apps.v1.namespaces('default').deployments.post({ body: deploymentManifest });
console.log('Create: ', create);
//
// Fetch the Deployment we just created.
//
const deployment = await client.apis.apps.v1.namespaces('default').deployments(deploymentManifest.metadata.name).get();
console.log('Deployment: ', deployment);
//
// Change the Deployment Replica count to 10
//
const replica = {
spec: {
replicas: 10
}
};
const replicaModify = await client.apis.apps.v1.namespaces('default').deployments(deploymentManifest.metadata.name).patch({ body: replica });
console.log('Replica Modification: ', replicaModify);
//
// Modify the image tag
//
const newImage = {
spec: {
template: {
spec: {
containers: [{
name: 'nginx',
image: 'nginx:1.8.1'
}]
}
}
}
};
const imageSet = await client.apis.apps.v1.namespaces('default').deployments(deploymentManifest.metadata.name).patch({ body: newImage });
console.log('New Image: ', imageSet);
//
// Remove the Deployment we created.
//
const removed = await client.apis.apps.v1.namespaces('default').deployments(deploymentManifest.metadata.name).delete();
console.log('Removed: ', removed);
} catch (err) {
console.error('Error: ', err);
}
}
main();发布于 2020-07-01 02:51:49
我推荐kubernetes-client/javascript。在我最喜欢原始API方法的所有API中,您可以看到一个示例这里。原因是
发布于 2018-10-22 14:12:15
https://stackoverflow.com/questions/52930720
复制相似问题