All Projects → godaddy → Kubernetes Client

godaddy / Kubernetes Client

Licence: mit
Simplified Kubernetes API client for Node.js.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Kubernetes Client

Unifi Api Browser
Tool to browse data exposed by Ubiquiti's UniFi Controller API (demo: https://api-browser-demo.artofwifi.net/)
Stars: ✭ 677 (-22.54%)
Mutual labels:  api-client
Cortex4py
Python API Client for Cortex
Stars: ✭ 22 (-97.48%)
Mutual labels:  api-client
Facepy
Facepy makes it really easy to use Facebook's Graph API with Python
Stars: ✭ 845 (-3.32%)
Mutual labels:  api-client
Client
GitLab API v4 client for PHP
Stars: ✭ 763 (-12.7%)
Mutual labels:  api-client
Slack
🎉✨ Slack API client for Node and browsers.
Stars: ✭ 903 (+3.32%)
Mutual labels:  api-client
Plex.py
Python interface for the Plex Media Server API
Stars: ✭ 22 (-97.48%)
Mutual labels:  api-client
Client
DigitalOcean API v2 client for PHP
Stars: ✭ 604 (-30.89%)
Mutual labels:  api-client
Genius Php
PHP library for Genius API (http://genius.com/developers)
Stars: ✭ 10 (-98.86%)
Mutual labels:  api-client
Algoliasearch Client Javascript
⚡️ A fully-featured and blazing-fast JavaScript API client to interact with Algolia.
Stars: ✭ 907 (+3.78%)
Mutual labels:  api-client
Puree
Metadata extraction from the Pure Research Information System.
Stars: ✭ 8 (-99.08%)
Mutual labels:  api-client
Pizzly
The simplest, fastest way to integrate your app with an OAuth API 😋
Stars: ✭ 796 (-8.92%)
Mutual labels:  api-client
Cv4pve Api Java
Proxmox VE Client API JAVA
Stars: ✭ 17 (-98.05%)
Mutual labels:  api-client
Automatic Client
Client wrapper for the Automatic Link
Stars: ✭ 22 (-97.48%)
Mutual labels:  api-client
Twitter
Twitter API for Laravel 5.5+, 6.x, 7.x & 8.x
Stars: ✭ 755 (-13.62%)
Mutual labels:  api-client
Abclinuxuapi
API for http://abclinuxu.cz.
Stars: ✭ 8 (-99.08%)
Mutual labels:  api-client
Pyowm
A Python wrapper around the OpenWeatherMap web API
Stars: ✭ 654 (-25.17%)
Mutual labels:  api-client
Groovehq
Ruby gem for GrooveHQ api
Stars: ✭ 22 (-97.48%)
Mutual labels:  api-client
Node Api.ai
[DEPRECATED] Ultimate Node.JS SDK for api.ai
Stars: ✭ 12 (-98.63%)
Mutual labels:  api-client
Visma.net
This is an open source API client for Visma.net Integrations
Stars: ✭ 10 (-98.86%)
Mutual labels:  api-client
Chingudevelopersnetwork
The Zoo
Stars: ✭ 26 (-97.03%)
Mutual labels:  api-client

kubernetes-client

Join Slack Build Status Greenkeeper badge

Simplified Kubernetes API client for Node.js.

Installation

Install via npm:

npm i kubernetes-client --save

Initializing

kubernetes-client generates a Kubernetes API client at runtime based on a Swagger / OpenAPI specification. You can generate a client using the cluster's kubeconfig file and that cluster's API specification.

To create the config required to make a client, you can either:

let kubernetes-client configure automatically by trying the KUBECONFIG environment variable first, then ~/.kube/config, then an in-cluster service account, and lastly settling on a default proxy configuration:

const client = new Client({ version: '1.13' })

provide your own path to a file:

const { KubeConfig } = require('kubernetes-client')
const kubeconfig = new KubeConfig()
kubeconfig.loadFromFile('~/some/path')
const Request = require('kubernetes-client/backends/request')

const backend = new Request({ kubeconfig })
const client = new Client({ backend, version: '1.13' })

provide a configuration object from memory:

// Should match the kubeconfig file format exactly
const config = {
  apiVersion: 'v1',
  clusters: [],
  contexts: [],
  'current-context': '',
  kind: 'Config',
  users: []
}
const { KubeConfig } = require('kubernetes-client')
const kubeconfig = new KubeConfig()
kubeconfig.loadFromString(JSON.stringify(config))

const Request = require('kubernetes-client/backends/request')
const backend = new Request({ kubeconfig })
const client = new Client({ backend, version: '1.13' })

and you can also specify the context by setting it in the kubeconfig object:

kubeconfig.setCurrentContext('dev')

You can also elide the .version and pass an OpenAPI specification:

const spec = require('./swagger.json')
const client = new Client({ spec })

or load a specification dynamically from the kube-apiserver:

const client = new Client()
await client.loadSpec()

See Examples for more configuration examples.

Basic usage

kubernetes-client translates Path Item Objects [1] (e.g., /api/v1/namespaces) to object chains ending in HTTP methods (e.g., api.v1.namespaces.get).

So, to fetch all Namespaces:

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

kubernetes-client translates Path Templating [2] (e.g., /apis/apps/v1/namespaces/{namespace}/deployments) to function calls (e.g., apis.apps.v1.namespaces('default').deployments).

So, to create a new Deployment in the default Namespace:

const deploymentManifest = require('./nginx-deployment.json')
const create = await client.apis.apps.v1.namespaces('default').deployments.post({ body: deploymentManifest })

and then fetch your newly created Deployment:

const deployment = await client.apis.apps.v1.namespaces('default').deployments(deploymentManifest.metadata.name).get()

and finally, remove the Deployment:

await client.apis.apps.v1.namespaces('default').deployments(deploymentManifest.metadata.name).delete()

kubernetes-client supports .delete, .get, .patch, .post, and .put.

Documentation

kubernetes-client generates documentation for the included specifications:

TypeScript

kubernetes-client includes a typings declartion file for Kubernetes API 1.13 and a complimentry Client1_13 class:

import * as ApiClient from 'kubernetes-client';

const Client = ApiClient.Client1_13;
const client = new Client({ version: '1.13' });

When using TypeScript, kubernetes-client does not support dynamically generating a client via .loadSpec().

Examples

examples/ has snippets for using kubernetes-client:

Contributing

See the kubernetes-client Issues if you're interested in helping out; and look over the CONTRIBUTING.md before submitting new Issues and Pull Requests.

Testing

Run the unit tests:

npm test

The integration tests use the current-context in your kubeconfig file. Run the integration tests:

npm run test-integration

Run integration tests with the @kubernetes/client-node backend:

KUBERNETES_CLIENT_BACKEND=client-node npm run test-integration

References

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].