npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

openshift-watch

v0.1.3

Published

Watch Openshift resources (fork of kube-watch)

Downloads

13

Readme

openshift-watch

Openshift Watch API for node.

Fork of kube-watch

Installation

$ npm i openshift-watch

Quick start

new OpenshiftWatch(resource, options) -> EventEmitter

import OpenshiftWatch from 'openshift-watch';

const deploymentconfigs = new OpenshiftWatch('deploymentconfigs', {
  url: 'https://openshiftserver:8443'   // Kubernetes API URL
});

deploymentconfigs
  .on('added', event => {
    console.log('Deployment Config %s added to namespace %s',
      event.metadata.name, event.metadata.namespace);
  })
  .on('modified', event => {
    // do something...
  })
  .on('deleted', event => {
    // ..do something else..
  })
  .on('error', err => {
    console.error('Error %d: %s', err.code, err.message);
  });

Watching resources

By default, openshift-watch will first request Kubernetes API to fetch the last resourceVersion for requested resource. See Kubernetes documentation for more details.
If you want to specify resourceVersion manually, see Query Parameters section.

Supported API & Resources

See Kubernetes API documentation for more details.

API v1

  • namespaces
  • endpoints
  • events
  • limitranges
  • persistentvolumeclaims
  • persistentvolumes
  • pods
  • podtemplates
  • replicationcontrollers
  • resourcequotas
  • secrets
  • serviceaccounts
  • service

API v1beta1

  • horizontalpodautoscalers
  • ingresses
  • jobs

** Openshift**

  • appliedclusterresourcequotas
  • buildconfigs
  • builds
  • clusternetworks
  • clusterresourcequotas
  • clusterrolebindings
  • clusterroles
  • deploymentconfigrollbacks
  • deploymentconfigs
  • egressnetworkpolicies
  • groups
  • hostsubnets
  • identities
  • images
  • imagesignatures
  • imagestreamimages
  • imagestreamimports
  • imagestreammappings
  • imagestreams
  • imagestreamtags
  • localresourceaccessreviews
  • localsubjectaccessreviews
  • netnamespaces
  • oauthaccesstokens
  • oauthauthorizetokens
  • oauthclientauthorizations
  • oauthclients
  • podsecuritypolicyreviews
  • podsecuritypolicyselfsubjectreviews
  • podsecuritypolicysubjectreviews
  • processedtemplates
  • projectrequests
  • projects
  • resourceaccessreviews
  • rolebindingrestrictions
  • rolebindings
  • roles
  • routes
  • selfsubjectrulesreviews
  • subjectaccessreviews
  • subjectrulesreviews
  • templates
  • useridentitymappings
  • user'

API version will be automatically selected depending on requested resource.

by namespace

Watch all services in namespace public :

const services = new OpenshiftWatch('services', {
  url: 'http://kube-api-server',
  namespace: 'public'
});

by name

Only watch service named www in namespace public :

const services = new OpenshiftWatch('services', {
  url: 'http://kube-api-server',
  namespace: 'public',
  name: 'www'
});

Filtering events

You can filter which events will be emitted using events option.
By default, openshift-watch will emit all k8s events: added, modified, deleted.

const namespaces = new OpenshiftWatch('namespaces', {
  url: 'http://openshift',
  events: [ 'added' ]   // watcher will only emit 'added' event
});

Query parameters

These extra query parameters are supported as option :

  • labelSelector
  • fieldSelector
  • resourceVersion
  • timeoutSeconds
const services = new OpenshiftWatch('services', {
  url: 'https://openshiftserver:8443',
  labelSelector: 'public-http',
  fieldSelector: 'event.status.podIP',
  resourceVersion: '6587423'
});

See documentation for more details about these options.

Request options

HTTP requests are performed using request package.
Pass custom options using request property.

const services = new OpenshiftWatch('services', {
  url: 'https://openshiftserver:8443',
  request: {
    timeout: 30000    // change HTTP request timeout
  }
});

HTTP Auth

See request's http authentication

const services = new OpenshiftWatch('services', {
  url: 'https://openshiftserver:8443',
  request: {
    auth: {
      user: 'foobar'
      pass: 'el8'
    }
  }
});

TLS/SSL support

See request's TLS/SSL support.

const services = new OpenshiftWatch('services', {
  url: 'https://openshiftserver:8443',
  request: {
    cert: fs.readFileSync(certFile),
    key: fs.readFileSync(keyFile),
    passphrase: 'password',
    ca: fs.readFileSync(caFile)
  }
});

Tests

Run test.js in watch mode :

$ env KUBE_API_SERVER=https://openshiftserver:8443 \
    npm run test:watch

Single run :

$ env KUBE_API_SERVER=https://openshiftserver:8443 \
    npm run test:single

Run tests using minikube to simulate workload.
See test/run-test.sh.

$ npm test

TODO

  • Improve test suites by simulating workload