3.7.0 • Published 3 months ago

@mittwald/kubernetes v3.7.0

Weekly downloads
17
License
MIT
Repository
-
Last release
3 months ago

Kubernetes client for Node.JS

npm version Build Status

Contents

Installation

You can install this package via NPM:

$ npm install @mittwald/kubernetes

Usage

Setup

External configuration using a kubeconfig file:

import {
  FileBasedConfig,
  KubernetesRESTClient,
  KubernetesAPI,
} from "@mittwald/kubernetes";

const config = new FileBasedConfig("/home/mhelmich/.kube/config");
const client = new KubernetesRESTClient(config);
const api = new KubernetesAPI(client);

Internal configuration (when the client is running within a Kubernetes cluster):

import {
  InClusterConfig,
  KubernetesRESTClient,
  KubernetesAPI,
} from "@mittwald/kubernetes";

const config = new InClusterConfig();
const client = new KubernetesRESTClient(config);
const api = new KubernetesAPI(client);

General usage

api
  .core()
  .v1()
  .pods.namespace("default")
  .list()
  .then((pods) => {
    console.log("Found " + pods.length + " Pods:");

    pods.forEach((pod) => {
      console.log(pod.metadata.name);
    });
  });

Rate-limiting API access

import {
  InClusterConfig,
  KubernetesRESTClient,
  RatelimitingKubernetesRESTClient,
  KubernetesAPI,
} from "@mittwald/kubernetes";

const config = new InClusterConfig();
const client = new KubernetesRESTClient(config);
const limitedClient = new RatelimitingKubernetesRESTClient(client);
const api = new KubernetesAPI(limitedClient);

Watching resources

api
  .core()
  .v1()
  .pods.namespace("default")
  .watch({ "some-label": "foo" }, (ev) => {
    console.log(`Pod: ${ev.type}: ${ev.object}`);
  });

Accessing CRDs

If you have a package that offers a client for Custom Resource Definitions (take a look at the @mittwald/kubernetes-rook package as an example), you can use the extend method to add the respective API client:

import { RookCustomResourceAPI } from "@mittwald/kubernetes-rook";

// ...
let extendedAPI = api.extend("rook", new RookCustomResourceAPI(client));

Supported resources

This library supports a reasonable subset of Kubernetes resources (these were implemented on an as-needed basis). Feel free to open a new issue or pull request to add support for additional API objects.

  • core/v1
    • pods
    • configMaps
    • endpoints
    • namespaces
    • nodes
    • persistentVolumes
    • persistentVolumeClaims
    • services
    • secrets
    • serviceAccounts
  • apps/v1
    • daemonSets
    • deployments
    • replicaSets
    • statefulSets
  • apps/v1beta1
    • deployments
    • statefulSets
  • batch/v1
    • jobs
  • batch/v1beta1
    • cronJobs
  • extensions/v1beta1
    • daemonSets
    • ingresses
    • networkPolicies
    • replicaSets
  • rbac/v1
    • clusterRoles
    • clusterRoleBindings
    • roles
    • roleBindings
  • autoscaling/v1
    • horizontalPodAutoscalers
  • apiextensions.k8s.io/v1beta1
    • customResourceDefinitions
  • admissionRegistration.k8s.io/v1
    • validatingWebhookConfigurations
    • mutatingWebhookConfigurations

References

3.7.0

3 months ago

3.5.2

4 months ago

3.6.0

1 year ago

3.5.1

11 months ago

3.5.0

1 year ago

3.4.2

2 years ago

3.4.1

2 years ago

3.4.0

2 years ago

3.3.5

3 years ago

3.3.0

3 years ago

3.2.2

4 years ago

3.2.1

4 years ago

3.2.0

4 years ago

3.1.0

4 years ago

3.0.2

5 years ago

3.0.1

5 years ago

3.0.0

5 years ago

2.6.1

5 years ago

2.6.0

5 years ago

2.5.2

5 years ago

2.5.1

5 years ago

2.5.0

5 years ago

2.3.4

5 years ago

2.3.3

5 years ago

2.3.2

5 years ago

2.3.1

6 years ago

2.3.0

6 years ago

2.2.0

6 years ago

2.1.2

6 years ago

2.1.1

6 years ago

2.1.0

6 years ago

2.0.0

6 years ago

2.0.0-beta.22

6 years ago

2.0.0-beta.21

6 years ago

2.0.0-beta.20

6 years ago

2.0.0-beta.19

6 years ago

2.0.0-beta.18

6 years ago

2.0.0-beta.17

6 years ago

2.0.0-beta.16

6 years ago

2.0.0-beta.12

6 years ago

2.0.0-beta.11

6 years ago

2.0.0-beta.10

6 years ago

2.0.0-beta.9

6 years ago

2.0.0-beta.8

6 years ago

2.0.0-beta.7

6 years ago

2.0.0-beta.6

6 years ago

2.0.0-beta.5

6 years ago

2.0.0-beta.4

6 years ago

2.0.0-beta.3

6 years ago

2.0.0-beta.2

6 years ago

2.0.0-beta.1

6 years ago