Search code examples
openshiftopenshift-3openshift-online

How to open an internal port in Openshift 3 Online?


Say if I want to open two ports, one for the public at 8080, and another one to process some public request but was forwarded by the 8080 port like such:

const http = require('http');
const publicServer = http.createServer(...).listen(8080);
const privateServer = http.createServer(...).listen(9999);
publicServer.on('connect', (req, cltSocket, head) => {
  ...
  if (...) {
    // let srvSocket = net.connect('9999', 'localhost', () => {
    let srvSocket = net.connect('9999', '127.0.0.1', () => {
      cltSocket.write('\r\n\r\n');
      srvSocket.write(head);
      srvSocket.pipe(cltSocket);
      cltSocket.pipe(srvSocket);
    });
  }
});

Is there some type of settings I can use to allow this? Currently it seems Openshift doesn't allow this setup. It is possible that it doesn't honor 127.0.0.1 or localhost and therefore not forwarding the request to the correct pod...


Solution

  • There should be no reason why you cant connect to port 9999 via localhost or 127.0.0.1 from any process in any container of the same pod.

    Have you tried using oc rsh to access the running container and gone:

    curl localhost:9999
    

    to verify that your code is actually listening properly on port 9999?