fib-k8s-client
Simplified Kubernetes API client for FIBJS, supported:
- Kubernetes API v1.13
- Kubernetes API v1.12
- Kubernetes API v1.11
- Kubernetes API v1.10
- Kubernetes API v1.9
- Kubernetes API v1.8
- Kubernetes API v1.7
Install
Via fibjs:
fibjs --install fib-k8s-client
Or, via npm:
npm install fib-k8s-client
Usage
config
/* * host: Kubernetes domain & port * version: API version * auth.token: Kubernetes access token */const conf = "host": "https://DOMAIN:PORT" "version": "1.13" "auth": "token": "k8s access token"
Client Initialization
const Client = ;client = conf;
Basic Usage
Access namespace list:
const namespaces = clientapiv1namespaces;
Create namespace:
const ns_json = ;clientnamespaces;
Access specific namespace:
clientapiv1namespaces'namespace_name';
Remove namespace:
clientapiv1namespaces'namespace_name';
Create pod:
const pod_json = ;clientapiv1namespaces'namespace_name'pods
Access pod from specific namespace:
clientapiv1namespaces'namespace_name'
remove pod:
clientapiv1namespaces'namespace_name';
fib-k8s-client supports .delete
, .get
, .patch
, .post
, and .put
.
You could find more detailed usage in test cases from test directory.
Full API interfaces documentation could find from docs directory(need download first):
Initialize client with API specification
You could use provided API specification json to init your API client:
const Client = ; const conf = "host": "https://DOMAIN:PORT" "auth": "token": "k8s access token" const spec = client = conf spec;
Testing
fibjs test