
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
nodeshift
Advanced tools
Nodeshift is an opinionated command line application and programmable API that you can use to deploy Node.js projects to OpenShift. It's currently under heavy development and APIs are still shifting a bit. However, in spite of its beta nature, you can use nodeshift today to deploy Node.js applications to OpenShift.
To install globally: npm install -g nodeshift
or to use in an npm script
npm install --save-dev nodeshift
// inside package.json
scripts: {
nodeshift: nodeshift
}
$ npm run nodeshift
By default, if you run just nodeshift
, it will run the deploy
goal, which is a shortcut for running resource
, build
and apply-resource
.
resource - will parse and create the application resources files on disk
apply-resource - does the resource goal and then deploys the resources to your running cluster
build - archives the code, creates a build config and imagestream and pushes the binary to the cluster
deploy - a shortcut for running resource
, build
and apply-resource
undeploy - removes resources that were deployed with the apply-resource command
.nodeshift
DirectoryThe .nodeshift
directory contains your resource fragements. These are .yml
files that describe your services, deployments, routes, etc. By default, nodeshift will create a Service
and DeploymentConfig
in memory, if none are provided. A Route
resource fragment should be provided or use the expose
flag if you want to expose your application to the outside world.
OpenShift resource fragments are user provided YAML files which describe and enhance your deployed resources. They are enriched with metadata, labels and more by nodeshift.
Each resource gets its own file, which contains some skeleton of a resource description. Nodeshift will enrich it and then combine all the resources into a single openshift.yml and openshift.json(located in ./tmp/nodeshift/resource/).
The resource object's Kind
, if not given, will be extracted from the filename.
Enrichers will add things to the resource fragments, like missing metadata and labels. If your project uses git, then annotations with the git branch and commit hash will be added to the metadata.
Default Enrichers will also create a default Service and DeploymentConfig when none are provided.
The default port value is 8080, but that can be overriden with the --deploy.port
flag.
You can also override this value by provideding a .nodeshift/deployment.yaml resource file
Some Resource Fragments might need to have a value set at "run time". For example, in the fragment below, we have the ${SSO_AUTH_SERVER_URL}
parameter:
apiVersion: v1
kind: Deployment
metadata:
name: nodejs-rest-http-secured
spec:
template:
spec:
containers:
- env:
- name: SSO_AUTH_SERVER_URL
value: "${SSO_AUTH_SERVER_URL}"
- name: REALM
value: master
To set that using nodeshift, use the -d
option with a KEY=VALUE, like this:
nodeshift -d SSO_AUTH_SERVER_URL=https://sercure-url
Along with the command line, there is also a public API. The API mirrors the commands.
API Docs - https://bucharest-gold.github.io/nodeshift/
resource
applyResource
build
deploy
undeploy
Options that you can specify on the command line, can also be passed as an options object to the API
All methods are Promise based and will return a JSON object with information about each goal that is run.
For example, if the deploy
method was run, it would return something similar:
{
build: {
... // build information
},
resources: [
... // resources created
],
appliedResources: [
... // resources that were applied to the running cluster
]
}
const nodeshift = require('nodeshift');
// Deploy an Application
nodeshift.deploy().then((response) => {
console.log(response);
console.log('Application Deployed')
}).catch((err) => {
console.log(err);
})
please note: Currently, once a route, service, deployment config, build config, and imagestream config are created, those are re-used. The only thing that changes from deployment to deployment is the source code. For application resources, you can update them by undeploying and then deploying again. BuildConfigs and Imagestreams can be re-created using the --build.recreate flag
While nodeshift is very opinionated about deployment parameters, both the CLI and the API accept options that allow you to customize nodeshift's behavior.
Outputs the current version of nodeshift
Changes the default location of where to look for your project. Defaults to your current working directory(CWD)
This option is passed through to the Openshift Rest Client for SSL use. To allow using a self-signed cert, set to false
This option is passed through to the Openshift Config Loader. Defaults to the ~/.kube/config
This option is passed through to the Openshift Config Loader. Set to false to by-pass service account lookup or use the KUBERNETES_AUTH_TRYSERVICEACCOUNT environment variable
Specify the version of Node.js to use for the deployed application. defaults to latest. These version tags corespond to the docker hub tags of the bucharest-gold s2i images
Specify the s2i builder image of Node.js to use for the deployed applications. Defaults to bucharestgold/centos7-s2i-nodejs
supress INFO and TRACE lines from output logs.
options to create a default route, if non is provided. Defaults to false
option to remove builds, buildConfigs and Imagestreams. Defaults to false - Only for the undeploy
Command
Flag to update the default ports on the resource files. Defaults to 8080
Flag to pass deployment config environment variables as NAME=Value. Can be used multiple times. ex: nodeshift --deploy.env NODE_ENV=development --deploy.env YARN_ENABLED=true
Flag to recreate a BuildConfig or Imagestream. Defaults to false. Choices are "buildConfig", "imageStream", false, true. If true, both are re-created
Flag to make your BuildConfig always pull a new image from dockerhub. Defaults to false
Flag to pass build config environment variables as NAME=Value. Can be used multiple times. ex: nodeshift --build.env NODE_ENV=development --build.env YARN_ENABLED=true
Shows the below help
Usage: nodeshift [--options]
Commands:
nodeshift deploy default command - deploy [default]
nodeshift build build command
nodeshift resource resource command
nodeshift apply-resource apply resource command
nodeshift undeploy undeploy resources
Options:
--version Show version number [boolean]
--projectLocation change the default location of the project [string]
--strictSSL setting to pass to the Openshift Rest Client. Set to
false if using a self-sign cert
--tryServiceAccount setting to pass to the Openshift Config Loader.
Set to false to by-pass service account lookup
or use the KUBERNETES_AUTH_TRYSERVICEACCOUNT
environment variable
--nodeVersion, -n the version of Node.js to use for the deployed
application.
[string] [choices: "latest", "9.x", "8.x", "7.x", "6.x", "5.x", "4.x"]
[default: "latest"]
--quiet supress INFO and TRACE lines from output logs
[boolean]
--expose flag to create a default Route and expose the default
service [boolean] [choices: true, false] [default: false]
--namespace flag to specify the project namespace to build/deploy
into. Overwrites any namespace settings in your OpenShift or Kubernetes configuration files
[string]
--deploy.port flag to update the default ports on the resource files.
Defaults to 8080 [default: 8080]
--build.recreate flag to recreate a buildConfig or Imagestream
[choices: "buildConfig", "imageStream", false, true] [default: false]
--build.forcePull flag to make your BuildConfig always pull a new image
from dockerhub or not
[boolean] [choices: true, false] [default: false]
--metadata.out determines what should be done with the response
metadata from OpenShift
[string] [choices: "stdout", "ignore", "<filename>"] [default: "ignore"]
--help Show help [boolean]
--cmd [default: "deploy"]
Please read the contributing guide
FAQs
Plugin for running openshift deployments
We found that nodeshift demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 9 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.