Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@kubernetes/client-node

Package Overview
Dependencies
Maintainers
2
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kubernetes/client-node

NodeJS client for kubernetes

  • 0.17.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created

What is @kubernetes/client-node?

@kubernetes/client-node is an official Kubernetes client library for Node.js. It allows developers to interact with Kubernetes clusters programmatically, providing a way to manage Kubernetes resources, perform CRUD operations, and watch for changes in the cluster.

What are @kubernetes/client-node's main functionalities?

CRUD Operations on Kubernetes Resources

This feature allows you to perform CRUD operations on Kubernetes resources. The code sample demonstrates how to list all pods in the default namespace.

const k8s = require('@kubernetes/client-node');
const kc = new k8s.KubeConfig();
kc.loadFromDefault();
const k8sApi = kc.makeApiClient(k8s.CoreV1Api);

// List all pods in the default namespace
k8sApi.listNamespacedPod('default').then((res) => {
  console.log(res.body);
});

Watch for Changes in the Cluster

This feature allows you to watch for changes in the Kubernetes cluster. The code sample demonstrates how to watch for changes in pods in the default namespace.

const k8s = require('@kubernetes/client-node');
const kc = new k8s.KubeConfig();
kc.loadFromDefault();
const watch = new k8s.Watch(kc);

// Watch for changes in pods in the default namespace
watch.watch('/api/v1/namespaces/default/pods', {},
  (type, obj) => {
    console.log(`Type: ${type}`);
    console.log(`Object: ${JSON.stringify(obj)}`);
  },
  (err) => {
    console.error(err);
  }
);

Custom Resource Definitions (CRDs)

This feature allows you to interact with Custom Resource Definitions (CRDs). The code sample demonstrates how to list all custom resources of a specific type in the default namespace.

const k8s = require('@kubernetes/client-node');
const kc = new k8s.KubeConfig();
kc.loadFromDefault();
const customObjectsApi = kc.makeApiClient(k8s.CustomObjectsApi);

// List all custom resources of a specific type
customObjectsApi.listNamespacedCustomObject('example.com', 'v1', 'default', 'examples').then((res) => {
  console.log(res.body);
});

Other packages similar to @kubernetes/client-node

Keywords

FAQs

Package last updated on 27 Jun 2022

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