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.