Functions

Functions are registered workflows (or sub-workflows) in a kontinue worker. A Function is written as regular Go code, for example:

func DeployCluster(ktx *kontinue.ExecutionContext, args *DeployArgs) (*DeployResult, error) {
    _ = kontinue.Sleep(ktx, 1 * time.Hour)
    return &DeployResult{}, nil
}

Functions can do anything — they can make API calls, compute results, or orchestrate infrastructure. The magic of kontinue comes in by checkpointing and making sub-executions durable, allowing execution to resume in the face of failures.

Registration

Functions are registered in worker startup:

worker.RegisterFunction(
    w,
    "deploy-cluster",
    DeployCluster,
    &function.Options{
        Description: "Run a deployment workflow with tests"
        Arguments:   function.ArgumentMetadata(&DeployArgs{}),
    },
)

This registration is what makes the Function discoverable to be executed in the future. Options control publishing additional metadata about the function — helpful descriptions and argument definitions. This metadata can be used by developers and operators and is exposed in the kontinue tooling (UI & CLI).

The worker also publishes the Function metadata as a CRD for API-driven usage:

$ kubectl get function deploy-cluster
NAME             DESCRIPTION                                  GROUP
deploy-cluster   Run a deployment workflow with tests         default

Calling Functions

Functions can be executed (or called) from many entrypoints:

  • kontinue tooling (e.g. kontinue execute CLI or the UI)
  • Creating an Execution resource directly via the Kubernetes API (or external tooling like Argo)
  • Using the kontinue client SDK

See the Execution docs for more details.