Skip to content

Conversation

@ash-darin
Copy link

@ash-darin ash-darin commented Sep 11, 2025

Summary

This change proposes a new environment variable $KBN_NODE_HOME , which will make it possible to switch the nodejs implementation that kibana uses. This is supposed to work analog to the $ES_JAVA_HOME variable.

"/bin/node" is appended to $KBN_NODE_HOME as the expected full path to the binary.

By providing KBN_NODE_HOME you can provide the path to a nodejs implementation that for example is not dependent on glibc-2.17 . Kibana could then ship with two nodejs binaries, one with glibc-2.17 support for RHEL 7 and one with support for modern glibc to offer an upgrade path away from the custom nodejs port.

By default (no environment variable is set) the current behaviour is preserved.

Identify risks

Supplying your own nodejs can break compatiblity, may lead to loss of data and invalidate support.

Release note

Provide an alternative nodejs binary via "KBN_NODE_HOME" environment variable, to support e.g. modern versions of glibc.

Make it configurable, which version of nodejs the user can use, analog to JAVA. This way either users can provide their own version of nodejs or Kibana can ship with two, one with glibc2.17 support for RHEL7 and one for modern glibc so users can switch.
@ash-darin ash-darin requested a review from a team as a code owner September 11, 2025 08:39
@jbudz
Copy link
Member

jbudz commented Sep 12, 2025

Thanks for the PR! Adding a KBN_NODE_HOME (small nit on the prefix, by convention we usually use KBN) makes sense to me. How would you feel about something like:

diff --git a/src/dev/build/tasks/bin/scripts/kibana b/src/dev/build/tasks/bin/scripts/kibana
index 1e2b1ba65a8..70b3ce5d08c 100755
--- a/src/dev/build/tasks/bin/scripts/kibana
+++ b/src/dev/build/tasks/bin/scripts/kibana
@@ -28,20 +28,25 @@ if [ -f "${CONFIG_DIR}/node.options" ]; then
   KBN_NODE_OPTS="$(grep -v ^# < ${CONFIG_DIR}/node.options | xargs)"
 fi
 
-{{#darwin}}
-NODE="${DIR}/node/default/bin/node"
-{{/darwin}}
-{{#linux}}
-NODE="${DIR}/node/glibc-217/bin/node"
-{{#serverless}}
-if [ "$KBN_ENABLE_POINTER_COMPRESSION" = 'true' ]; then
+if [ -n "$KBN_NODE_HOME" ]; then
+  NODE="${KBN_NODE_HOME}/bin/node"
+else
+  {{#darwin}}
+  NODE="${DIR}/node/default/bin/node"
+  {{/darwin}}
+  {{#linux}}
+  NODE="${DIR}/node/glibc-217/bin/node"
+  {{#serverless}}
+  if [ "$KBN_ENABLE_POINTER_COMPRESSION" = 'true' ]; then
+    NODE="${DIR}/node/pointer-compression/bin/node"
+  fi
+  {{/serverless}}
+  {{#forcePointerCompression}}
   NODE="${DIR}/node/pointer-compression/bin/node"
+  {{/forcePointerCompression}}
+  {{/linux}}
 fi
-{{/serverless}}
-{{#forcePointerCompression}}
-NODE="${DIR}/node/pointer-compression/bin/node"
-{{/forcePointerCompression}}
-{{/linux}}
 test_node
 
 # Enable capturing heap snapshots. See https://nodejs.org/api/cli.html#--heapsnapshot-signalsignal
diff --git a/src/dev/build/tasks/bin/scripts/kibana.bat b/src/dev/build/tasks/bin/scripts/kibana.bat
index 80040138cd8..165a2047bb4 100755
--- a/src/dev/build/tasks/bin/scripts/kibana.bat
+++ b/src/dev/build/tasks/bin/scripts/kibana.bat
@@ -5,7 +5,11 @@ SETLOCAL ENABLEDELAYEDEXPANSION
 set SCRIPT_DIR=%~dp0
 for %%I in ("%SCRIPT_DIR%..") do set DIR=%%~dpfI
 
-set NODE=%DIR%\node\default\node.exe
+If Not "%KBN_NODE_HOME%"=="" (
+  set "NODE=%KBN_NODE_HOME%\bin\node.exe"
+) Else (
+  set "NODE=%DIR%\node\default\node.exe"
+)
 set NODE_ENV=production
 
 If Not Exist "%NODE%" (

A little more complexity, but makes it work in all our environments. Also a few notes for kibana.bat. If this makes sense to you we can also make updates to all the bin scripts in this folder, and add a note in our documentation.

@jbudz jbudz added the Team:Operations Kibana-Operations Team label Sep 12, 2025
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-operations (Team:Operations)

@ash-darin
Copy link
Author

ash-darin commented Sep 15, 2025

Hi,

thank you for the hint about the KBN_ style environment variables, I missed this. You are right, we could expand on this PR and I could add this to the other scripts in the directory. I'd only update the *nix scipts though. I am unfamiliar with the Windows environment, so would like to leave this to someone else.

I'd use a construct like this though:

If Defined KBN_NODE_HOME (
  set "NODE=%KBN_NODE_HOME%\bin\node.exe"
) Else (
  set "NODE=%DIR%\node\default\node.exe"
)

if - Windows Documentation

@ash-darin
Copy link
Author

@jbudz I now amended all files as suggested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💝community Team:Operations Kibana-Operations Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants