- examples/pg-query/handler.py: Python function querying PostgreSQL invocations table - examples/pg-query/requirements.txt: psycopg2-binary==2.9.9 - examples/pg-query/main.tf: terraform config for sless_function + sless_trigger - internal/api/handler/upload.go: generateDockerfile() now accepts hasRequirements bool - scans zip for requirements.txt at upload time - adds RUN pip install --no-cache-dir to Dockerfile when requirements.txt present - doc/progress.md: updated status for pg-query e2e task
5.8 KiB
5.8 KiB
Прогресс разработки
Последнее обновление: 2026-03-07
Статусы: ✅ готово | 🔄 в процессе | ⏳ не начато
v1 — Базовый сервис
Код
| # | Компонент | Статус | Заметки |
|---|---|---|---|
| 1 | Структура проекта, operator-sdk init | ✅ | module: gitea-naeel.giteak8s.services.ngcloud.ru/naeel/sless |
| 2 | CRD types: Function, Trigger | ✅ | api/v1alpha1/, zz_generated.deepcopy.go |
| 3 | internal/config | ✅ | config.go, Load() из env vars, добавлены IngressHost + APIToken |
| 4 | Миграции PostgreSQL | ✅ | migrations/001_initial.sql — таблица invocations |
| 5 | internal/storage/postgres | ✅ | store.go: SaveInvocation, ListInvocations, RunMigrations |
| 6 | internal/storage/s3 | ✅ | client.go: Upload, Download, Delete, EnsureBucket (Ceph S3) |
| 7 | internal/builder | ✅ | builder.go: kaniko Jobs для сборки образов функций |
| 8 | controllers/function_controller.go | ✅ | Pending→Building(kaniko)→Ready/Failed, Deployment, finalizer |
| 9 | controllers/trigger_controller.go | ✅ | HTTP→Service+Ingress, Cron→CronJob, finalizer |
| 10 | internal/api/router.go | ✅ | gorilla/mux, /v1/namespaces/{ns}/... |
| 11 | internal/api/handler/ | ✅ | functions.go, triggers.go, invocations.go, handler.go (slog) |
| 12 | internal/api/middleware/ | ✅ | auth.go (Bearer token), logging.go (slog) |
| 13 | main.go | ✅ | operator manager + HTTP сервер параллельно, wire всех зависимостей |
Кластер (namespace: sless)
| # | Ресурс | Статус | Заметки |
|---|---|---|---|
| 1 | namespace sless | ✅ | создан |
| 2 | CRD functions.sless.kube5s.ru | ✅ | установлен из config/crd/bases/ |
| 3 | CRD triggers.sless.kube5s.ru | ✅ | установлен из config/crd/bases/ |
| 4 | ServiceAccount sless-operator | ✅ | deployments/k8s/rbac.yaml |
| 5 | ClusterRole + ClusterRoleBinding | ✅ | deployments/k8s/rbac.yaml |
| 6 | PostgreSQL Deployment + Service | ✅ | deployments/k8s/postgres.yaml, Running |
| 7 | Secret postgres-secret | ✅ | в namespace sless |
Runtime image + Upload endpoint (2026-03-07)
| # | Компонент | Статус | Заметки |
|---|---|---|---|
| 1 | runtimes/python3.11/server.py | ✅ | HTTP wrapper :8080, loads /app/function/handler.py |
| 2 | runtimes/python3.11/Dockerfile | ✅ | FROM python:3.11-slim, naeel/sless-runtime-python3.11:latest |
| 3 | Secret sless-registry-auth | ✅ | DockerHub creds для kaniko в namespace sless |
| 4 | internal/api/handler/upload.go | ✅ | POST /v1/namespaces/{ns}/functions/{name}/upload |
| 5 | Fix: kaniko S3 endpoint | ✅ | https:// + S3_FORCE_PATH_STYLE=true (Ceph) |
| 6 | Fix: бесконечный цикл сборки | ✅ | idempotency guard через аннотацию last-built-s3key |
E2E тест (2026-03-07)
| # | Шаг | Результат |
|---|---|---|
| 1 | Запуск оператора локально | ✅ source hack/local.env && go run main.go |
| 2 | Создание функции hello + upload handler.zip | ✅ kaniko собрал naeel/sless-default-hello:latest |
| 3 | Function phase=Ready, Deployment Running | ✅ namespace sless-fn-default |
| 4 | GET /health |
✅ {"status": "ok"} |
| 5 | POST / {"name":"Naeel"} |
✅ {"message": "Hello, Naeel!"} |
Terraform провайдер (2026-03-07)
| # | Компонент | Статус | Заметки |
|---|---|---|---|
| 1 | terraform/provider/ — независимый Go-модуль | ✅ | module: terraform-provider-sless |
| 2 | internal/client/client.go | ✅ | HTTP-клиент sless API, готов к переносу в nubes |
| 3 | internal/provider/provider.go | ✅ | паттерн идентичен nubes NubesProvider |
| 4 | sless_function resource | ✅ | CRUD + upload zip + WaitReady (kaniko) |
| 5 | sless_trigger resource | ✅ | CRUD (http/cron) |
| 6 | hack/build-and-publish.sh | ✅ | GPG-подпись + mc upload в S3 |
| 7 | Публикация в terra.k8c.ru | ✅ | v0.1.0, key CB3A0DF161ECC416 |
| 8 | terraform init | ✅ | Installed terra.k8c.ru/naeel/sless v0.1.0 |
Примечание: Код провайдера писался с прицелом на перенос в nubes провайдер.
internal/client/ → internal/core/ nubes, ресурсы → internal/resources_gen/.
Что ещё не сделано
| # | Компонент | Статус | Заметки |
|---|---|---|---|
| 1 | terraform apply e2e — функция с postgres | 🔄 В процессе | examples/pg-query/{handler.py,requirements.txt,main.tf} созданы; upload.go поддерживает requirements.txt; поднять среду + terraform apply |
| 2 | HTTP trigger e2e тест | ⏳ | Service+Ingress через TriggerController |
| 3 | deployments/k8s/operator.yaml | ⏳ | Deployment оператора в кластере |
| 4 | Перенос ресурсов sless в nubes провайдер | ⏳ | после e2e тестирования |
v2 — Расширения
| # | Компонент | Статус | Заметки |
|---|---|---|---|
| 1 | RabbitMQ event triggers | ⏳ | |
| 2 | Облачный auth (nubes.ru token validation) | ⏳ | v1 — статический токен |
| 3 | Метрики → Victoria Metrics | ⏳ | |
| 4 | Managed PostgreSQL от провайдера | ⏳ | сейчас postgres в k8s |
| 5 | Pre-warm для cron триггеров | ⏳ | TriggerSpec.PreWarmSeconds — поле есть, логика не реализована |