cup icon indicating copy to clipboard operation
cup copied to clipboard

Simplify packaging and configuring controllers

Open GeorgeMac opened this issue 2 years ago • 1 comments

More often than not, controllers will be defined and scoped to a set of supported resource types.

For example, the Flipt controller handles Flipt and Segment resource types only.

It should therefor be possible to bundle both the Controller WASM binary and its support definitions in a single artefact. The most promising format is likely OCI.

With the https://github.com/oras-project/oras-go project we could add support for bundling WASM binaries with their associated resources type directly into cup and cupd. cupd could support sourcing controllers and definitions directly from OCI registries.

Here are some useful links for design ideas around packing:

Quick sketch of what a manifest might look like for cup:

{
  "schemaVersion": 2,
  "artifactType": "application/vnd.io.flipt.cup.controller+type",
  "config": {
    "mediaType": "application/vnd.oci.empty.v1+json",
    "digest": "sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a",
    "size": 2
  },
  "layers": [
    {
      "mediaType": "application/vnd.io.flipt.cup.controller.content.v1.tar+gzip",
      "digest": "sha256:1b251d38cfe948dfc0a5745b7af5ca574ecb61e52aed10b19039db39af6e1617",
      "size": 7364
    },
    {
      "mediaType": "application/vnd.io.flipt.cup.resource.v1+json",
      "digest": "sha256:3e207b409db364b595ba862cdc12be96dcdad8e36c59a03b7b3b61c946a5741a",
      "size": 384
    }
  ]
}

cup subcommands

One of more new subcommand(s) would be useful for packing, publishing and pulling Cup controllers.

We will need to support users being able to:

  • bundle together wasm controller binaries with resource definitions
  • pushing named and tagged images to OCI registries
  • (optional/stretch) pulling and unpacking / introspecting remote images

cupd controller definition

The Controller definition will need extending to support referencing a registry and tag. The controller will need to:

  • establish a local or inmemory oras store
  • copy the target from the remote into the store (if local we could cache between starts of cup somewhere)
  • configure the resource definitions found in the image
  • compile and configure the controller with the wasm binary

GeorgeMac avatar Aug 01 '23 17:08 GeorgeMac

Something like the following could also be preferable: https://github.com/solo-io/wasm/blob/master/spec/spec-compat.md

This is the solo.io WASM format, that is compatible with docker build and push. That would make the tooling a lot easier to get going with. If you have Docker, it could just be a json file next to a wasm binary with a well-known name or configurable name in the well-known configuration file.

GeorgeMac avatar Aug 21 '23 12:08 GeorgeMac