feat: operator v0.1.16 — job stdout -> status.Message (feature B)

- FunctionJobReconciler: added KubeClient field (kubernetes.Interface)
- getJobPodOutput(): reads pod logs via typed client after job succeeds
- main.go: inject kubernetes.NewForConfigOrDie into FunctionJobReconciler
- rbac.yaml: add pods/pods/log get/list/watch permissions
- examples/simple-python/: job->function chain demo (Python)
- examples/simple-node/: job->function chain demo (Node.js)

sless_job.X.message now contains the return value of the function
This commit is contained in:
“Naeel”
2026-03-09 14:50:06 +04:00
parent 53d9fa6e74
commit 0aaeb47b3b
19 changed files with 330 additions and 4 deletions
+38
View File
@@ -0,0 +1,38 @@
# Создано: 2026-03-09
# time-getter.tf — одноразовая функция + джоб запускающий её при apply.
# sless_job.run_getter.message после apply содержит stdout runner-а:
# {"time": "2026-03-09T12:34:56.789012+00:00"}
# Это значение terraform записывает в env JOB_TIME функции time_display.
# Упаковываем код функции в zip
data "archive_file" "time_getter_zip" {
type = "zip"
source_dir = "${path.module}/code/time_getter"
output_path = "${path.module}/dist/time_getter.zip"
}
# Функция-вычислитель: запускается только джобом, не имеет HTTP-триггера
resource "sless_function" "time_getter" {
namespace = "default"
name = "simple-py-time-getter"
runtime = "python3.11"
entrypoint = "time_getter.get_time"
memory_mb = 64
code_path = data.archive_file.time_getter_zip.output_path
code_hash = filesha256("${path.module}/code/time_getter/time_getter.py")
}
# Джоб: запускает time_getter один раз при terraform apply.
# run_id > 0 — разрешение на запуск (run_id=0 пропускается оператором).
# После завершения message = stdout пода = json возвращённый get_time().
resource "sless_job" "run_getter" {
namespace = "default"
name = "simple-py-getter-run"
function = sless_function.time_getter.name
run_id = 1
wait_timeout_sec = 120
event_json = "{}"
depends_on = [sless_function.time_getter]
}