Giter VIP home page Giter VIP logo

kubernetes.client's Introduction

kubernetes.client

Build Status

kubernetes.client is an opinionated javascript client for Kubernetes clusters.

Warning: This project is currently under active development and is subject to breaking changes without notice.

Installing

Install with yarn:

yarn add @containership/kubernetes.client

Install with npm:

npm install @containership/kubernetes.client --save

Usage

Setting up the client

You can pull remote cluster information from an existing kubeconfig file:

const client = new KubernetesClient({
    config: KubernetesClient.Config.fromKubeConfig({
        kubeConfig: ~/.kube/config,
        context: 'my-context',
    }),
    version: '1.10'
});

If you know the version of Kubernetes the cluster is running, you can specify it when setting up the client. If not, you can always dynamically load the cluster API spec (this is preferred).

After setting up a initial client config, run the following command:

await client.loadSpec()

Once you have loaded the cluster specification either dynamically or from specifying an initial Kubernetes version, you have access to all the resources from the client.resources object.

For example, to list all the Deployments on the cluster in the default namespace, just run the following:

const deployments = await client.resources.Deployment.list()

You can specify a specific namespace and many other configurable parameters through the builder API.

const customNamespaceDeployments = await client.resources.Deployment.namespace('custom').list()

The client even supports pagination out of the box. You just pass a configured resource call to the paginate method, and it handles fetching and combining all the resources into a single list response!

const allDeployments = await KubernetesClient.paginate(client.resources.Deployment.allNamespaces().limit(25))

Extensive usage documentation and examples will become available as the project matures.

Contributing

Thank you for your interest in this project and for your interest in contributing! Feel free to open issues for feature requests, bugs, or even just questions - we love feedback and want to hear from you.

PRs are also always welcome! However, if the feature you're considering adding is fairly large in scope, please consider opening an issue for discussion first.

Inspiration

https://github.com/godaddy/kubernetes-client

We loved the way the kubernetes-client automatically generated user friendly APIs from cluster OpenAPI specs. With all this additional knowledge, we didn't think end users should have to understand which API version of resources they need to deal with to communicate with a cluster. We flipped the concept and provide a powerful way to interact with clusters without having to specify API versions, but still expose that flexibility to you if needed.

kubernetes.client's People

Contributors

nicktate avatar williamkunz avatar normanjoyner avatar mattkelly avatar desaias avatar

Stargazers

 avatar Dan Kelly avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.