Files
sless/examples/hello-node/job.tf
T
“Naeel” e6abc490cd fix: imagePullSecrets, SLESS_ENTRYPOINT, registry secret propagation
- function_controller: добавить RegistrySecret + OperatorNamespace, копировать
  sless-registry-auth в sless-fn-<ns>, выставлять imagePullSecrets в Deployment,
  также обновлять imagePullSecrets при reconcile
- functionjob_controller: fnEnvVars включает SLESS_ENTRYPOINT, runner читает его
- server.js + server.py: читать SLESS_ENTRYPOINT вместо hardcoded handler.js/py
- rbac.yaml: добавить права на secrets
- operator.yaml: v0.1.8
- main.go: передать RegistrySecret + OperatorNamespace в FunctionReconciler
2026-03-08 11:15:48 +04:00

52 lines
1.6 KiB
Terraform

# 2026-03-08
# job.tf — одноразовая функция: суммирует числа из переданного массива.
# Код: code/handler-job.js
#
# Использование:
# terraform apply
# # apply блокируется до завершения джоба (~2 мин kaniko + выполнение)
# terraform output job_message
#
# Повторный запуск — изменить event_json и снова terraform apply.
data "archive_file" "handler_job" {
type = "zip"
source_file = "${path.module}/code/handler-job.js"
output_path = "${path.module}/handler-job.zip"
}
resource "sless_function" "hello_job" {
namespace = "default"
name = "hello-job"
runtime = "nodejs20"
entrypoint = "handler-job.handle"
memory_mb = 128
timeout_sec = 30
code_path = data.archive_file.handler_job.output_path
code_hash = data.archive_file.handler_job.output_md5
}
# Одноразовый запуск. Все поля immutable — изменение любого пересоздаёт джоб.
# run_id: 0 = не запускать, 1+ = запустить. Для повторного запуска увеличь run_id (1→2→3...).
resource "sless_job" "hello_run" {
namespace = "default"
name = "hello-run"
function = sless_function.hello_job.name
event_json = jsonencode({ numbers = [1, 2, 3, 4, 5] })
wait_timeout_sec = 600
run_id = 1
}
output "job_phase" {
value = sless_job.hello_run.phase
}
output "job_message" {
value = sless_job.hello_run.message
}
output "job_completion_time" {
value = sless_job.hello_run.completion_time
}