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

js-kube-client

v0.2.1

Published

A javascript client for Kubernetes API

Downloads

7

Readme

js-kube-client

A Javascript client dedicated to in-cluster Kubernetes jobs

Maintenance HitCount npm

Description

For those wanting to use Nodejs to interface Kubernetes API, here is been developed an API using native nodejs modules, to be used as deployment that manages jobs.

Prerequisites

  • nodejs 12.x +
  • docker 18.x +
  • kubernetes 1.17.0 (checked)

Build a docker container

  1. Install docker https://docs.docker.com/install/ and build image:
docker build -t gh3s/js-kube-client -f build/Dockerfile .
  1. Install kubernetes https://kubernetes.io/docs/setup/

Testing using local server

  1. Delete 'cluster' in index.js.
const deployment = new Deployment('cluster')
const cronjob = new CronJob('cluster')
  1. Start server
npm start test <port>

cluster is a string for in-cluster appliances, default is for test purposes

  1. Deploy a test deployment in your cluster and test the code:
apply -f test/testjob.yaml
  1. Wait the job starts and search for it.
curl localhost:<port>/job?name=pi-with-ttl

Run in Kubernetes

  1. Apply the deployment.yaml:
kubectl apply -f kubernetes/deployment.yaml
  1. Apply service.yaml:
kubectl apply -f kubernetes/service.yaml
  1. Create a job using a POST request to <nodeip>:<nodeport> where <nodeip> is a worker node IP. Use this JSON data for test purposes:
const jobYaml = {
  "apiVersion": "batch/v1",
  "kind": "Job",
  "metadata": {
      "name": "pi-with-ttl"
  },
  "spec": {
      "ttlSecondsAfterFinished": 10,
      "template": {
          "spec": {
              "containers": [{
                  "name": "pi",
                  "image": "perl",
                  "command": [
                      "perl",
                      "-Mbignum=bpi",
                      "-wle",
                      "print bpi(2000)"
                  ]
              }],
              "restartPolicy": "Never"
          }
      }
  }
}
  1. Verify the job with a GET request to <nodeip>:<nodeport>/job?name=pi-with-ttl

  2. Delete the job with a DELETE request to the same address.

NOTES:

  1. For minikube testing: minikube service --url js-kube-client

  2. For GKE consider RBAC yaml file inside kubernetes folder

To update bundle

Update version in:

  1. kubernetes/deployment.yaml

  2. build/Dockerfile

  3. package.json using 'npm init'

  4. commit modifications and push to remote

  5. publish npm

  6. push to dockerhub

Release History

  • 0.0.1
    • CHANGE: Work in progress
  • 0.0.3
    • ADDED: Deployments and cronjobs
  • 0.0.5
    • ADDED: Persistent volumes and Persistent volume claims
  • 0.1.0
    • UPDATE: Security faults corrected
  • 0.1.1
    • ADDED: GKE RBAC yaml file
  • 0.2.1
    • UPDATE: Security faults corrected
    • UPDATE: 4crud updated

Authors

License

This project is licensed under the MIT License - see the LICENSE file for details

Contributing

  1. Fork it (https://github.com/gh3s/js-kube-client/fork)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request