Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement systemd unikernel manager #1466

Open
craciunoiuc opened this issue Mar 27, 2024 · 1 comment · May be fixed by #1537
Open

Implement systemd unikernel manager #1466

craciunoiuc opened this issue Mar 27, 2024 · 1 comment · May be fixed by #1537
Labels
kind/enhancement New feature or request priority/low Nice to have issues thatare not urgent, but can be nagging.

Comments

@craciunoiuc
Copy link
Member

craciunoiuc commented Mar 27, 2024

Feature request summary

This issue tracks the ability to set and manage Unikraft unikernels as individual systemd entries. Ultimately this would give users the ability to use unikernels as secure, persistent system services.

At a glance, creating and managing unikernels as systemd processes should be designed to be simple, making it an effective mechanism and alternative approach for system services. As such, a new flag --systemd should be provided to the following subcommands to enable managing and running via this interface:

  • kraft run --systemd [...]
  • kraft start --systemd [...]
  • kraft stop --systemd [...]
  • kraft rm --systemd [...]
  • kraft ps --systemd [...]

In order to prevent large disruption to the individual subcommand codebases, (i.e. preventing having a large if opts.Systemd flag with a different line-of-execution), a simple wrapper around the machine API can be used to proxy all interface methods into relevant systemd service management actions.

In order to propagate such functionality, a new machine service implementation is required in kraftkit.sh/machine/platform/systemd which implements the MachineService interface:

// MachineService is the interface of available methods which can be performed
// by an implementing machine platform driver.
type MachineService interface {
Create(context.Context, *Machine) (*Machine, error)
Start(context.Context, *Machine) (*Machine, error)
Pause(context.Context, *Machine) (*Machine, error)
Stop(context.Context, *Machine) (*Machine, error)
Update(context.Context, *Machine) (*Machine, error)
Delete(context.Context, *Machine) (*Machine, error)
Get(context.Context, *Machine) (*Machine, error)
List(context.Context, *MachineList) (*MachineList, error)
Watch(context.Context, *Machine) (chan *Machine, chan error, error)
Logs(context.Context, *Machine) (chan string, chan error, error)
}

To utilize the machine API via a controller, it should be a simple case of wrapping an existing controller, e.g.:

import (
  machineapi "kraftkit.sh/api/machine/v1alpha1"
  "kraftkit.sh/machine/platform/systemd"
)

var controller machineapi.MachineService

if opts.Systemd {
  controller, err = systemd.NewMachineV1alpha1ServiceSystemdWrapper(ctx, controller)
  if err != nil {
    // [...]
  }
}

The new method NewMachineV1alpha1ServiceSystemdWrapper will consume all interface methods and directly interface with systemd which can be accomplished with this existing Go module.

Warning

Installing systemd process should ultimately create an entry which invokes kraft itself and that not all interface methods are a simple 1-to-1 call of one another. This is because wrapper will pass through the machine API store twice and some verbs do not map directly to the machine API. Careful consideration should be practice when proxying commands. For example, the Create command should both create the systemd service entry and also initialize the unikernel. The Start method, however, could, only start the systemd service as this will invoke kraft which will actually start the unikernel.

Additional context

@MdSahil-oss wants to work on this.

@craciunoiuc craciunoiuc added the kind/enhancement New feature or request label Mar 27, 2024
@nderjung
Copy link
Member

I have updated the issue text with more verbose information about this particular feature request.

@nderjung nderjung changed the title Implement systemd unikernel manager Implement systemd unikernel manager Mar 27, 2024
@MdSahil-oss MdSahil-oss linked a pull request Apr 10, 2024 that will close this issue
4 tasks
@craciunoiuc craciunoiuc added the priority/low Nice to have issues thatare not urgent, but can be nagging. label Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement New feature or request priority/low Nice to have issues thatare not urgent, but can be nagging.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants