rik-org / rik

RIK is an experimental workload orchestrator that allows you to deploy your cloud applications, written in Rust.
https://rik-org.github.io/rik/
Apache License 2.0
68 stars 11 forks source link

Add abstraction level around runtimes (containers/VMs) #56

Closed alexandrebrg closed 1 year ago

alexandrebrg commented 1 year ago

Context

A lot of work has been done to have something working in RIK, especially in Riklet. Either to run containers or VMs. We'd like to keep things simple and add an abstraction around methods that are deploying workloads. The idea is to create a trait (or more) in order to define an implementation of a runtime based on workload kind (Function or Pod).

The responsability of those implementation should be kept to deploying the infrastructure to run a workload, this doesn't concern network. For instance, FunctionRuntimeInstance is expected to download a rootFS and start the microVM with ability to monitor it. Same goes for PodRuntimeInstance, it only create linux namespaces and do a chroot (I simplified).

Network implementation will be handed by those runtime with a specific trait. The responsability of this trait is to give a contextual implementation of the network. We expect this implementation to only contain two methods for now: up and down, which refer to setup and cleanup of the network. Below is the simpliest trait that can be used. In case you determine more is needed, you can add arguments. The contract defined here won't tell you which IP are available and that's normal, we can easily determine that IP X.X.X.[0|1|254] are used by the provider (0 is the network, 1 is the gateway, 254 is a reserved IP).

impl trait MySuperNetwork {
   // IETH is a name of network interface 
   fn up(network: Ipv4, out_interface: IEth, ip_mask: u16): Result<(), NetworkError>
   fn down(): Result<(), NetworkError>
}

What needs to be done ?

This work can be divided into several PRs.