Documentation
¶
Index ¶
Constants ¶
const ( LabelApp = "app" LabelFunction = "function" AppDeployer = "deployer" )
Labels every deployer Job carries. The controller's cleanup selects on them, so both sides use these constants.
const ObservedByLabel = "kdex.dev/observed-by"
ObservedByLabel marks a KDexFunction as a member of a host's observer set. The per-host observer CronJob lists by it, so the observed set stays exactly the adaptor-deployed functions -- service-backed functions never had an observer and still don't. Must match the constant in knative-deployer's cmd/main.go. See kdex-tech/host-manager#156.
Variables ¶
This section is empty.
Functions ¶
func HostObserverName ¶ added in v0.4.23
HostObserverName is the per-host observer CronJob's name.
func JobName ¶ added in v0.30.1
func JobName(function *kdexv1alpha1.KDexFunction) string
JobName is the deployer Job for a function's current state: its generation, its executable image and the FaaS adaptor generation, so a change to any of them deploys again. Every other deployer Job for the function is obsolete once finished, and the controller deletes it (#282). The current one is kept, finished or not: its pod holds the termination message and, for a terminal failure, the logs an operator inspects (#27).
Types ¶
type Deployer ¶
type Deployer struct {
Client client.Client
FaaSAdaptor kdexv1alpha1.KDexFaaSAdaptorSpec
Host kdexv1alpha1.KDexInternalHost
ImagePullSecrets []corev1.LocalObjectReference
Scheme *runtime.Scheme
ServiceAccount string
// TokenPrefix is the host's resolved white-label PASETO API token prefix
// (per-host spec or NexusConfiguration default). Injected as
// PASETO_TOKEN_PREFIX so the function's verifier can restore the
// "v4.public." header. Empty => bare tokens (no prefixing). It MUST be the
// same value the host's TokenManager mints with.
TokenPrefix string
}
func (*Deployer) Deploy ¶
func (d *Deployer) Deploy(ctx context.Context, function *kdexv1alpha1.KDexFunction) (*batchv1.Job, error)
The FaaS adaptor is responsible for deploying the function. Since there are virtually unlimited number of ways to deploy a function, we use a job as a bridge between the Nexus controller and the FaaS adaptor. The workload provided by the FaaS adaptor knows how to deploy the function. Whether the functions are deployed on KNative, AWS Lambda, Google Cloud Functions, Azure Functions, or something else is irrelevant to the Nexus controller. The job is responsible for deploying the function and reporting the status of the deployment back to the Nexus controller. The job must return success or failure along with reasons, and upon success, at least the URL of the function so that the Focal Controller can mount it into the host's service mesh and dispatch requests to it.
func (*Deployer) Observe ¶
func (d *Deployer) Observe(ctx context.Context, function *kdexv1alpha1.KDexFunction) (client.Object, error)
Observe converges the host's observer CronJob onto the current FaaSAdaptor.Observer spec and enrolls the function in its observed set.
Two defects are addressed here.
#143: this used to reconcile only Spec.Schedule on an existing CronJob and apply the full pod template only on the create path, so an adaptor edit (image, tolerations, nodeSelector, env, securityContext) never reached functions that already had an observer. The desired spec is now rebuilt every pass and written whenever it differs, so any triggered reconcile -- including the periodic resync -- heals a stale observer.
#156: observers used to be one CronJob per function, all sharing the adaptor's single schedule, so every observer in a namespace fired in the same second and object count grew with the fleet. There is now one CronJob per host; the function is marked with ObservedByLabel and the observer resolves its set from that label. Any legacy per-function CronJob found is retired.
type Runtime ¶
type Runtime interface {
// Deploy returns a Job that, when executed, will deploy or update the function.
// The Job is expected to update the KDexFunction status upon completion.
Deploy(ctx context.Context, function *kdexv1alpha1.KDexFunction) (*batchv1.Job, error)
// Observe returns a workload that, when executed, calls the provider API to check status.
// For external providers, this is likely a CronJob.
// For K8s-native providers (like Knative), this might return nil (if handled by standard Watch),
// or a no-op Job for consistency.
Observe(ctx context.Context, function *kdexv1alpha1.KDexFunction) (client.Object, error)
}
Runtime defines the interface for interacting with a FaaS provider.