Skip to Content
Personal Insights
Author's profile photo Marco Dorn

Changing the function runtime version of a running function

In this short post, I want to share my personal learning when changing the runtime version of a live function inside SAP BTP, Kyma runtime. This might come in handy when a Node.js version is getting deprecated, and you don’t want to create a copy of that function from scratch, but get it built again so that a new pod backed by the updated runtime version replaces the existing one without a downtime.

Nevertheless, always first test the function code with the new Node.js version to ensure it is indeed building. Don’t just update the version of a function runtime to then discover it’s not building anymore because of incompatible changes inside the Node.js version.

Editing the function object using vi

Now I am exposing what little Unix knowledge I have. I want to help others who are at the same Unix-level as I am. You will use the text editor “vi” living inside the Linux-based container of the function to edit the runtime version. To do so, use your favorite command line interface and edit the configuration of the particular function object with

kubectl edit functions.serverless.kyma-project.io <function_name> -n <namespace>

This will open its configuration using vi.

  • Move to the line which defines the “runtime”, e.g. “runtime: nodejs12”.
  • Move the curser to the end of that line and press “Delete” to remove the “2”.
  • Push “a” to be able to insert a character to the right of the cursor.
  • Insert a “4” so that the line says “runtime: nodejs14”.
  • Press escape.
  • Type in “:wq” and hit “Enter”.

It will save the file exit vi. If you want to abort, type in “:q!” instead and hit enter to cancel without saving.

You can see the function being built again and the new pod replaces the existing one.

Assigned Tags

      3 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Denys van Kempen
      Denys van Kempen

      Alternatively, you can use search/replace

      # search and replace
      :s/js12/js14/
      # save and exit
      :wq

      For those less familiar with vi (or vim), you can use the KUBE_EDITOR environment variable to point to the editor of your preference, e.g.

      KUBE_EDITOR="nano" kubectl edit ....

      On macOS, the format is

      # generic format
      export KUBE_EDITOR=‘open -a “<application_name>” --wait’
      # VS Code
      export KUBE_EDITOR='open -a "Visual Studio Code" --wait'

      On Windows, navigate to Advanced system settings > System Properties > Advanced tab, then select Environment Variables to create a variable named as KUBE_EDITOR with the value pointing to the path of your favorite text editor.

      Author's profile photo Marco Dorn
      Marco Dorn
      Blog Post Author

      Thanks Denys van Kempen! That is a very good addition.

      Author's profile photo Piotr Tesny
      Piotr Tesny

      Hey Marco Dorn .

      Indeed this is important to change the nodejs runtime version for kyma fynctions to the latest and supported one.

      Good news is that can be done using the kyma dashboard GUI interface as well. Actually I had to do it recently for all my "historical" lambdas...

      For instance:

      cheers; Piotr