Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node.js Deployment in openshift

I was trying to deploy a Node.js application to the openshift as in this link here

I understand this code

var http = require('http');

var server = http.createServer(function(req, res) {
    res.writeHead(200);
    res.end('Hello Http');
});
server.listen(3000);

and there is no issue running it locally

$ node server.js // saved as server.js

However, how does this work when I commit this application in openshift? This is very simple code. I have some downloaded code that is a chat application and client-server need to configure to listen on some port (I was using port number 3000 in my localhost).

It works on port number 3000 in localhost but how can I make it to work in Openshift?

like image 960
jeewan Avatar asked Oct 08 '13 18:10

jeewan


People also ask

What are OpenShift deployments?

What Is a Deployment? OpenShift Container Platform deployments provide fine-grained management over common user applications. They are described using three separate API objects: A deployment configuration, which describes the desired state of a particular component of the application as a pod template.

What is a node in OpenShift?

About nodes. A node is a virtual or bare-metal machine in a Kubernetes cluster. Worker nodes host your application containers, grouped as pods. The control plane nodes run services that are required to control the Kubernetes cluster.

Is OpenShift a deployment tool?

Red Hat OpenShift is a leading enterprise Kubernetes platform1 that enables a cloud-like experience everywhere it's deployed. Whether it's in the cloud, on-premise or at the edge, Red Hat OpenShift gives you the ability to choose where you build, deploy, and run applications through a consistent experience.


1 Answers

You need to listen on port process.env.OPENSHIFT_NODEJS_PORT. So something like this should work:

server.listen(process.env.OPENSHIFT_NODEJS_PORT || 3000);

See here for example: Error: listen EACCES on Openshift app

like image 113
Nitzan Shaked Avatar answered Nov 15 '22 07:11

Nitzan Shaked