# Enclave-CC proposal for the Confidential Containers Operator The Confidential Containers Operator is the front door of the Confidential Containers project, a project that's an umbrella covering a whole lot of different projects and different technologies. ## What is needed from Enclave-CC The needed components from Enclave-CC are: * Enclave Agent bundle * Boot Instance bundle * Shim * Rune / Runc * A payload image Let's go through each one of the components, and explore what should be done for those. ### Preconditions * Occlum libOS (with enclave-cc modifications) installable from a binaries to builder/build container to get _boot instance_ bundle build. * Use a vanilla distro w/ Linux 5.11+ (in-tree SGX driver available). ### Enclave Agent bundle This should be built inside/as a container, and the result should be a tarball added to the payload image and eventually decompressed to `/opt/confidential-containers/share/enclave-cc/bundles/agent`. The`Dockerfile` shall 1) install (enclave-cc) Occlum, get enclave signing key 2) clone and build enclave agent 3) create/package Occlum instance 4) copy Occlum instance to the final image 5) install Occlum-runtime and SGX SDK to the final image ### Boot Instance bundle This should be built inside/as a container, and the result should be a tarball added to the payload image and eventually decompressed to `/opt/confidential-containers/share/enclave-cc/bundles/boot-instance` The `Dockerfile` shall 1) install (enclave-cc) Occlum, get enclave signing key 2) clone and build boot init binary 3) create/package Occlum instance 4) copy Occlum instance to the final image 5) install Occlum-runtime and SGX SDK to the final image ### Shim This should be built inside a container, and the result should be a tarball that can decompressed at `/opt/confidential-containers/bin`. ### Rune / Runc Here we have two alternative paths that we should consider. #### Runc Nothing is needed, as the `runc` already present on the node would be used. #### Rune This should be built inside a container, and the result should be a tarball that can be decompressed at `/opt/confidential-containers/bin`. Rune brings Occlum as a dependency, and Occlum brings SGX-SDK as a dependency. Those would have to also be packaged and most likely installed under `/opt/confidential-containers/share/`. steps: TBD ### Payload image The payload image should mimic what's been already done for Kata Containers. A Dockerfile that can be used to generate the image can be found at https://github.com/kata-containers/kata-containers/blob/CCv0/tools/packaging/kata-deploy-cc/Dockerfile, where the only change needed is on the following variables: https://github.com/kata-containers/kata-containers/blob/f5a65223989b090c91e94faf933ce256fc6e6c9b/tools/packaging/kata-deploy-cc/Dockerfile#L8-L9 (and, the same variable names throughout the dockerfile). This payload will take as argument a tarball, a single tarball, that should be the merge of the tarballs provided for the items mentioned above. The scripts used to install and uninstall such content, can be found at https://github.com/kata-containers/kata-containers/blob/CCv0/tools/packaging/kata-deploy-cc/scripts/kata-deploy.sh, and the parts that need to be changed are: * Shim names: https://github.com/kata-containers/kata-containers/blob/f5a65223989b090c91e94faf933ce256fc6e6c9b/tools/packaging/kata-deploy-cc/scripts/kata-deploy.sh#L14-L21 * Enclave-CC will only have one "shim" to be configured / added as part of containerd runtime table * The install artifacts directory: https://github.com/kata-containers/kata-containers/blob/f5a65223989b090c91e94faf933ce256fc6e6c9b/tools/packaging/kata-deploy-cc/scripts/kata-deploy.sh#L55-L59 * Maybe the shim configuration: https://github.com/kata-containers/kata-containers/blob/f5a65223989b090c91e94faf933ce256fc6e6c9b/tools/packaging/kata-deploy-cc/scripts/kata-deploy.sh#L87 * The containerd configuration: https://github.com/kata-containers/kata-containers/blob/f5a65223989b090c91e94faf933ce256fc6e6c9b/tools/packaging/kata-deploy-cc/scripts/kata-deploy.sh#L140 * The content to be cleaned up: https://github.com/kata-containers/kata-containers/blob/f5a65223989b090c91e94faf933ce256fc6e6c9b/tools/packaging/kata-deploy-cc/scripts/kata-deploy.sh#L198 If those bits are changed, the image should be good to be used with the Operator. Mind that, on the operator side, a new sample configuration will have to be created for the Enclave-CC, and that can be done based on: https://github.com/confidential-containers/operator/blob/main/config/samples/ccruntime.yaml ## Recommended Actions While we work on the plan for rune vs. runc installation the following can be started: 1. start the enclave-cc specific `CcRuntime` based on ccruntime.yaml (the containerd installation part, performed by the preInstall and postUninstall hooks, should remain common to kata-cc) 2. setup enclave-cc payload and install enclave agent bundle build using 0.28.1 Occlum release repos 3. update enclave-cc payload to install boot instance bundle 4. update enclave-cc payload to install shim-enclave binary 5. get the payload image published