- 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)"}
46 lines
1.1 KiB
HCL
46 lines
1.1 KiB
HCL
# 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
|
|
}
|