feat: add nodejs20 runtime
- runtimes/nodejs20/server.js: HTTP wrapper, exports.handle(event)
- runtimes/nodejs20/Dockerfile: node:20-alpine base image
- naeel/sless-runtime-nodejs20:v0.1.0 pushed to DockerHub
- upload.go: nodejs20 in runtimeBaseImage(), package.json → npm install
- upload.go: python3.11 now uses v0.1.0 tag (no more latest)
- operator v0.1.2 deployed in cluster
- E2E: hello-node-default.fn.kube5s.ru → {"message":"Hello, Naeel! (nodejs20)"}
This commit is contained in:
parent
6ba398f98c
commit
96664148e0
6
hello-node/handler.js
Normal file
6
hello-node/handler.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
// handler.js — пример serverless функции на Node.js 20
|
||||||
|
// Возвращает приветствие с именем из event или "World" по умолчанию
|
||||||
|
exports.handle = async (event) => {
|
||||||
|
const name = event.name || 'World';
|
||||||
|
return { message: `Hello, ${name}! (nodejs20)` };
|
||||||
|
};
|
||||||
45
hello-node/main.tf
Normal file
45
hello-node/main.tf
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
# 2026-03-07
|
||||||
|
# main.tf — e2e тест: hello-world функция на Node.js 20.
|
||||||
|
#
|
||||||
|
# Использование:
|
||||||
|
# 1. terraform init && terraform apply
|
||||||
|
# 2. После apply (~2 мин kaniko):
|
||||||
|
# curl -s -X POST <trigger_url> -H 'Content-Type: application/json' -d '{"name":"Naeel"}'
|
||||||
|
# Ожидаемый ответ: {"message":"Hello, Naeel! (nodejs20)"}
|
||||||
|
|
||||||
|
terraform {
|
||||||
|
required_providers {
|
||||||
|
sless = {
|
||||||
|
source = "terra.k8c.ru/naeel/sless"
|
||||||
|
version = "~> 0.1.1"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
provider "sless" {
|
||||||
|
endpoint = "https://sless-api.kube5s.ru"
|
||||||
|
token = "dev-token-change-me"
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "sless_function" "hello_node" {
|
||||||
|
namespace = "default"
|
||||||
|
name = "hello-node"
|
||||||
|
runtime = "nodejs20"
|
||||||
|
entrypoint = "handler.handle"
|
||||||
|
memory_mb = 128
|
||||||
|
timeout_sec = 30
|
||||||
|
|
||||||
|
code_path = "${path.module}/handler.zip"
|
||||||
|
code_hash = filemd5("${path.module}/handler.zip")
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "sless_trigger" "hello_node_http" {
|
||||||
|
namespace = "default"
|
||||||
|
name = "hello-node-http"
|
||||||
|
type = "http"
|
||||||
|
function = sless_function.hello_node.name
|
||||||
|
}
|
||||||
|
|
||||||
|
output "trigger_url" {
|
||||||
|
value = sless_trigger.hello_node_http.url
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user