Workloads
A workload is a definition of a piece of software that should be run on a cluster. It can be seen as a collection of containers, VM and other resources that are required to run a software. Defining a workload won't deploy an instance immediately, but it will be used as a definition to deploy an instance.
The implementation only support JSON format, but the API is designed to be extensible to support other formats in the future. In case you expect to have a specific format, please open an issue to discuss it.
RIK supports two types of workload:
- Pod: A pod is a collection of containers that should be run together. As you might imagine in Kubernetes, for each instance, they will be packed together and share the same resource limits. They are the most basic workload type, and they are used to run a single application.
- Function1: A function is a definition for a microVM that should be running in a more isolated way than a pod. This kind of workload supports network capabilities, it means it can be exposed easily on the network.
Lifecycle
Workloads have a common lifecycle which goes through various states. Each time the state is updated at any step of the lifecycle, the scheduler and the controller are aware of it and will act accordingly. In the case a failure is detected, the controller won't try to recover the workload, but it will give the error message to the user.
sequenceDiagram actor Bob participant Primary as RIK Primary Node participant Scheduler as RIK Scheduler participant Secondary as RIK Secondary Node Bob-->>Primary: Request new instance <br/>of a workload note over Primary: Status: PENDING Primary-->>Scheduler: Request Schedule note over Scheduler: Status: PENDING Scheduler-->>Secondary: Determine appropriate node and<br/> order scheduler note over Secondary: Status: CREATING Secondary-->>Secondary: Download and run <br/> necessary components note over Secondary: Status: RUNNING Secondary-->>Scheduler: Return instance running OK Scheduler-->>Primary: Return instance running OK Primary-->>Bob: Return instance running OK
JSON Schema Reference
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://rik-org.github.io/rik/workloads/schema-v1.json",
"title": "Workload-v1",
"description": "Reference for workload in RIK with apiVersion v1",
"type": "object",
"properties": {
"apiVersion": {
"description": "The version associated to the current schema",
"type": "string",
"default": "v1"
},
"kind": {
"description": "The kind of the resource",
"type": "string",
"enum": [ "Pod", "Function" ]
},
"name": {
"description": "Unique name of the workload",
"type": "string"
},
"replicas": {
"description": "Number of replicas expected (won't be deployed)",
"type": "integer",
"minimum": 1
},
"spec": {
"description": "Full specification of the workload",
"type": "object",
"required": [ "containers", "function" ],
"properties": {
"containers": {
"description": "List of containers to be deployed",
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Name of the container"
},
"image": {
"type": "string",
"description": "Image to be used for the container"
},
}
}
},
"function": {
"description": "Function to be deployed",
"type": "object",
"properties": {
"execution": {
"type": "object",
"properties": {
"rootfs": {
"type": "string",
"description": "Rootfs to be used for the container, must a be URL that can be publicly accesed"
}
}
}
}
}
}
}
},
"required": [ "apiVersion", "kind", "name", "replicas", "spec" ]
}
This workload will probably be renamed in the future, as it is not
strictly related to functions.