The Propeller K8s Operator is a Kubernetes operator designed to manage and schedule tasks on a fleet of devices, which can be either Kubernetes pods or external devices. It introduces two custom resources: Proplet and Task.
The operator enables users to define a pool of worker nodes (Proplets) and schedule tasks (Tasks) to be executed on them. This is particularly useful for IoT and edge computing scenarios where tasks need to be offloaded to a distributed network of devices.
- Hybrid Worker Management: Manage both Kubernetes-native workers (as
Deployments) and external devices (e.g., IoT devices, bare-metal servers) as a unified pool of resources. - Task Scheduling: A sophisticated scheduling mechanism that allows
Tasksto specify requirements for thePropletsthey can run on. This includes resource requirements, device capabilities, and label-based selection. - MQTT Integration: The operator communicates with external
Propletsvia the MQTT protocol, allowing for real-time status updates and task management. - Extensible Scheduling: The scheduling logic is pluggable, with a round-robin scheduler provided by default.
The operator introduces two Custom Resource Definitions (CRDs):
A Proplet represents a worker node that is available to execute Tasks. There are two types of Proplets:
k8s: APropletthat is managed by the operator and runs as aDeploymentwithin the Kubernetes cluster.external: APropletthat represents an external device. These devices are expected to communicate with the operator via MQTT.
Example Proplet (k8s):
apiVersion: propeller.propeller.abstractmachines.fr/v1
kind: Proplet
metadata:
name: my-k8s-proplet
spec:
type: k8s
k8s:
image: my-worker-image:latest
logLevel: info
replicas: 1
connectionConfig:
# ... MQTT connection detailsExample Proplet (external):
apiVersion: propeller.propeller.abstractmachines.fr/v1
kind: Proplet
metadata:
name: my-external-proplet
spec:
type: external
external:
deviceType: raspberry-pi
capabilities:
- gpio
- sensor
connectionConfig:
# ... MQTT connection detailsA Task represents a unit of work to be executed on a Proplet. It specifies the function to be executed, any required inputs, and constraints for selecting a suitable Proplet.
Example Task:
apiVersion: propeller.propeller.abstractmachines.fr/v1
kind: Task
metadata:
name: my-task
spec:
functionName: "process-data"
propletSelector:
matchCapabilities:
- sensor
resourceRequirements:
cpu: "500m"
memory: "256Mi"The operator consists of two main controllers:
PropletReconciler: This controller is responsible for managing the lifecycle ofPropletresources. Fork8sProplets, it creates and manages a correspondingDeployment. ForexternalProplets, it monitors their health via MQTT liveness messages.TaskReconciler: This controller manages the lifecycle ofTaskresources. It finds a suitablePropletbased on theTask's requirements, schedules theTaskto aProplet, and then monitors theTask's execution.
The operator uses MQTT to communicate with external Proplets. The communication is structured around a base topic, and the operator subscribes to topics for liveness and task results, and publishes messages to start tasks.
To get started with the Propeller K8s Operator, you will need:
- A Kubernetes cluster.
kubectlinstalled and configured to communicate with your cluster.- An MQTT broker accessible from your cluster.
-
Clone the repository:
git clone https://github.com/absmach/propeller-k8s-operator.git cd propeller-k8s-operator -
Install the CRDs:
make install
-
Deploy the operator:
make deploy
-
Create a
Proplet:Create a file named
my-proplet.yamlwith the contents similar to example-propletApply the manifest:
kubectl apply -f my-proplet.yaml
-
Create a
Task:Create a file named
my-task.yamlwith the contents similar to example-taskApply the manifest:
kubectl apply -f my-task.yaml
The operator will now schedule the Task to the Proplet.
To contribute to the development of the Propeller K8s Operator, you will need:
- Go (version 1.24 or higher)
- Docker
make
make buildmake testThis project is licensed under the Apache 2.0 License - see the LICENSE file for details.