New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@mittwald/kubernetes

Package Overview
Dependencies
Maintainers
2
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mittwald/kubernetes

Kubernetes client library

  • 3.7.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
168
increased by242.86%
Maintainers
2
Weekly downloads
 
Created
Source

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

FAQs

Package last updated on 29 Feb 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc