fib-k8s-client

0.0.4 • Public • Published

fib-k8s-client

NPM version

README:中文 | English

Simplified Kubernetes API client for FIBJS, supported:

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 } = require('fib-k8s-client');
client = new Client(conf);

Basic Usage

Access namespace list:

const namespaces = client.api.v1.namespaces.get();

Create namespace:

const ns_json = require('./namespace.json');
client.namespaces.create(ns_json);

Access specific namespace:

client.api.v1.namespaces('namespace_name').get();

Remove namespace:

client.api.v1.namespaces('namespace_name').delete();

Create pod:

const pod_json = require('./pod.json');
client.api.v1.namespaces('namespace_name').pods.post({ body: pod_json })

Access pod from specific namespace:

client.api.v1.namespaces('namespace_name').pods('pod_name').get()

remove pod:

client.api.v1.namespaces('namespace_name').pods('pod_name').delete();

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 } = require('fib-k8s-client');
 
const conf = {
    "host": "https://DOMAIN:PORT",
    "auth": {
        "token": "k8s access token"
    }
}
 
const spec = require("./api_spec.json")
 
client = new Client(conf, spec);

Testing

fibjs test

License

GPL - 3.0

Package Sidebar

Install

npm i fib-k8s-client

Weekly Downloads

1

Version

0.0.4

License

GPL-3.0

Unpacked Size

2.29 MB

Total Files

23

Last publish

Collaborators

  • d3j