https://github.com/mcasimir/kubernetes-api-client
Kubernetes api client with support for async/await, watch for resources and auto conf
https://github.com/mcasimir/kubernetes-api-client
kubernetes kubernetes-api nodejs
Last synced: 2 months ago
JSON representation
Kubernetes api client with support for async/await, watch for resources and auto conf
- Host: GitHub
- URL: https://github.com/mcasimir/kubernetes-api-client
- Owner: mcasimir
- Created: 2018-01-21T17:28:31.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-01-22T10:30:12.000Z (over 7 years ago)
- Last Synced: 2025-01-28T03:17:37.613Z (4 months ago)
- Topics: kubernetes, kubernetes-api, nodejs
- Language: JavaScript
- Size: 287 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Kubernetes Api Client for Node.js
## Install
```
npm install --save kubernetes-api-client
```## Usage
``` js
const KubernetesApiClient = require('kubernetes-api-client');const k8s = new KubernetesApiClient();
async function main() {
const {items} = await k8s.get('api/v1/namespaces');console.info('Available namespaces:');
for (const ns of items) {
console.info('-', ns.metadata.name);
}console.info('Waiting for namespace events:');
const nsId = `test-ns-${Date.now()}`;
setTimeout(function() {
k8s.post('api/v1/namespaces', {
metadata: {
name: nsId
}
});
}, 3000);setTimeout(function() {
k8s.delete(`api/v1/namespaces/${nsId}`);
}, 6000);await k8s.watch('v1/namespaces', function({type, object: ns}) {
if (type === 'ADDED') {
console.info('Namespace added:', ns.metadata.name);
}if (type === 'MODIFIED') {
console.info('Namespace modified:', ns.metadata.name);
}if (type === 'DELETED') {
console.info('Namespace deleted:', ns.metadata.name);
}
});}
main().catch(function(err) {
console.error(err);
process.exit(1);
});
```## Getting Started