feat: add FunctionJob CRD for one-shot function runs

- api/v1alpha1/job_types.go: new CRD FunctionJob (Pending/Running/Succeeded/Failed)
- controllers/functionjob_controller.go: reconciler creates k8s Job from FunctionRef + EventJSON
- zz_generated.deepcopy.go: DeepCopy methods for FunctionJob types
- config/crd/bases: generated CRD YAML, applied to cluster
- main.go: register FunctionJobReconciler
- rbac.yaml: add functionjobs permissions
- operator.yaml: v0.1.2 -> v0.1.3
- operator:v0.1.3 deployed and running in cluster
This commit is contained in:
“Naeel”
2026-03-07 17:20:21 +04:00
parent d6dc676dfd
commit 22685a72a9
7 changed files with 529 additions and 6 deletions
@@ -0,0 +1,93 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.14.0
name: functionjobs.sless.kube5s.ru
spec:
group: sless.kube5s.ru
names:
kind: FunctionJob
listKind: FunctionJobList
plural: functionjobs
singular: functionjob
scope: Namespaced
versions:
- additionalPrinterColumns:
- jsonPath: .spec.functionRef
name: Function
type: string
- jsonPath: .status.phase
name: Phase
type: string
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
name: v1alpha1
schema:
openAPIV3Schema:
description: |-
FunctionJob — ресурс для одноразового запуска serverless функции.
Создаётся пользователем через terraform ресурс sless_job.
После завершения (Succeeded/Failed) ресурс остаётся в кластере для аудита.
properties:
apiVersion:
description: |-
APIVersion defines the versioned schema of this representation of an object.
Servers should convert recognized schemas to the latest internal value, and
may reject unrecognized values.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
type: string
kind:
description: |-
Kind is a string value representing the REST resource this object represents.
Servers may infer this from the endpoint the client submits requests to.
Cannot be updated.
In CamelCase.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
type: string
metadata:
type: object
spec:
description: FunctionJobSpec — параметры одноразового запуска функции.
properties:
eventJson:
default: '{}'
description: |-
EventJSON — данные передаваемые в handle(event) в JSON формате.
Если не задан — передаётся пустой объект {}.
Пример: {"action": "migrate", "version": "002"}
type: string
functionRef:
description: FunctionRef — имя Function ресурса в том же namespace
type: string
required:
- functionRef
type: object
status:
description: FunctionJobStatus — наблюдаемое состояние (заполняет контроллер).
properties:
completionTime:
description: CompletionTime — время завершения
format: date-time
type: string
jobName:
description: JobName — имя созданного k8s Job
type: string
message:
description: Message — результат выполнения или сообщение об ошибке
type: string
phase:
description: 'Phase — текущая фаза: Pending, Running, Succeeded, Failed'
type: string
startTime:
description: StartTime — время запуска k8s Job
format: date-time
type: string
type: object
type: object
served: true
storage: true
subresources:
status: {}