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

okd-runner

v0.2.8

Published

Self deploying Node.JS applications in OpenShift.

Downloads

47

Readme

OKD-runner

This library helps to write self-deploying Node.js applications for OpenShift and soon in Kubernetes.

Setup

Now this guide assume you got an OpenShift cluster up and running, if you don't, you still can get access to OpenShift Online for free or setup one in your computer via Minishift or oc cluster-up.

Once you have OpenShift sorted out, you'll need to create a project/namespace manually, you can do this by login into the console and clicking into new project, thats the only limitation of the module at the moment of not being able to create it for you.

Getting Started

Before continue you'll need an OpenShift cluster up and running, the easiest way is to subscribe here OpenShift Online for free or if you feel strong you can setup one in your computer via Minishift or oc cluster-up.

Once you have OpenShift sorted out, you'll need to create a project/namespace manually, you can do this by login into the web console and clicking into new project.

Self Deploying

Now we should get back to our working directory and install okd-runner module from npm, this is the module that does the magic:

npm install install okd-runner --save

We add the module:

let count = 0

const run = require('okd-runner') // <- self-deploy module

require('http')
    .createServer((req, res) => {
        res.end(`<HTML>
                    <h1>Hello From -> ${process.platform}</h1>
                    <h2>Visitor: ${count++} </h2>
                </HTML>`)
        console.log(`response: ${Date.now()}`)
    }).listen(8080)

By adding this module you still can run your application locally, the only difference is that now you can choose a different execution runtime by passing the --cloud flag, this flag will tell your JS program to run in OpenShift:

  node app --cloud   # or node app -c for short
  • The first time it will ask you for your cluster credentials:

  • And also to choose the namespace/project:

Runtime

After that your application will start the deployment:

...
building  ok
URL:  http://my-app-dev-01.7e14.starter-us-west-2.openshiftapps.com
...
...
npm info using [email protected]
npm info lifecycle [email protected]~prestart: [email protected]
npm info lifecycle [email protected]~start: [email protected]

> [email protected] start /opt/app-root/src
> node app.js

response: 1550511176623
...

Here you can see the logs of you container plus the URL, to exit you just need to press Ctrl-C and you will get back to your console.

Updating

From now everything is similar as to run your application locally, let's add a line of code to get the pods name, this way showcase how we can make an update:

let count = 0
const run = require('okd-runner')
console.log('listening in 8080')
require('http')
    .createServer((req, res) => {
        res.end(`<HTML>
                    <h1>Hello From ${process.platform}</h1>
                    <h2>Visitors ${count++} </h2>

                    <!-- changes -->
                    <p>Pod ${require('os').hostname()}<p>
                    <img src="https://media.giphy.com/media/12NUbkX6p4xOO4/giphy.gif">
                    <!--         -->

                </HTML>`)
        console.log(`response: ${Date.now()}`)
    }).listen(8080)

We run our application again:

  node app --cloud

This time it goes straight to deployment.

Cleaning up

To remove your application you just need to pass the -rm flag:

node app -rm

You see not a single YAML file, hope this module helps you simplify your workflow while developing Node.JS micro-services. Also this module is still under development so feel free to contribute by sending suggestions, pull request, improvements or by opening an issue.