madana-cluster

by MADANA

Helm chartv0.0.3Verified publisher

Madana Core Cluster Dependencies

About this chart

Madana Core Cluster Setup

Install SGX Driver Manually

To be able to deploy enclaves, the linux kernel needs to have the proper SGX kernel module loaded. The following steps guide you through this process, ensuring persistence between kernel updates via a systemd startup service.

download intel sgx driver installer to static location

apt install -y make gcc linux-headers-generic
mkdir /opt/intel
curl https://download.01.org/intel-sgx/sgx-linux/2.7.1/distro/ubuntu18.04-server/sgx_linux_x64_driver_2.6.0_4f5bb63.bin -o /opt/intel/sgxdriver.bin
chmod +x /opt/intel/sgxdriver.bin

add startup script that installs the sgx module for every new kernel

cat <<EOF > /etc/systemd/system/install-sgx-driver.service
[Unit]
Description=Install sgx driver and modprobe isgx if /dev/isgx not present
After=udev.service
ConditionPathExists=!/dev/isgx
AssertPathExists=/opt/intel/sgxdriver.bin

[Service]
Type=oneshot
ExecStart=/bin/sh -c "/opt/intel/sgxdriver.bin && /sbin/modprobe isgx"
RemainAfterExit=true

[Install]
WantedBy=multi-user.target
EOF

# enable service
systemctl enable --now install-sgx-driver

symlink /dev/isgx to /dev/sgx to make the sgx-device-plugin work

echo 'KERNEL=="isgx", SYMLINK+="sgx"' > /etc/udev/rules.d/99_isgx.rules

Enable support for Thread-Local Storage (TLS) via sgx-lkl (volatile)

git clone https://gitlab.com/madana-io/core/madana-cluster
cd ./madana-cluster/kmod-set-fsgsbase/
make set-cr4-fsgsbase

Enable support for Thread-Local Storage (TLS) via sgx-lkl (persistent)

git clone https://gitlab.com/madana-io/core/madana-cluster
cp -r ./madana-cluster/kmod-set-fsgsbase/ /opt/

cat <<EOF > /etc/systemd/system/enable-tls.service
[Unit]
Description=Enable support for Thread-Local Storage (TLS) via sgx-lkl persistently
AssertPathExists=/opt/kmod-set-fsgsbase/Makefile
AssertPathExists=/opt/kmod-set-fsgsbase/mod_set_cr4_fsgsbase.c

[Service]
Type=oneshot
ExecStart=/usr/bin/make -C /opt/kmod-set-fsgsbase/ set-cr4-fsgsbase
RemainAfterExit=true

[Install]
WantedBy=multi-user.target
EOF

# enable service
systemctl enable --now enable-tls

Install SGX Driver via Ansible

WIP

Deploy Madana Cluster Helm Chart

Madana Node and Madana Enclave services are statically configured to reach services provided by the Madana Cluster via the namespace madana-system. Be sure to deploy this chart to this namespace as otherwise these services will not be reachable.

kubectl namespace create madana-system
helm install --namespace madana-system madana-cluster .

The following services are provided with this chart

  • ipfs - standalone enclaves will connect with this ipfs server to download enclave environments
  • cpu-affinity-service - keeps track of the cpu usage and assigns enclaves dynamically to cpu resources
  • aesmd - intels aesm daemon
  • sgx-device-plugin - allows us to mount the /dev/sgx device into the enclaves container without granting it priviledged access

Third party dependencies

In addition to installing the Madana Cluster Helm Chart, these dependencies exist and need to be installed, otherwise certain features will not be available:

  • nginx-ingress-controller - used to forward madana nodes http backend
  • cert-manager - used to secure madana nodes http backend with lets encrypt
  • persistent storage driver - integral part of madana node and madana enclave, without persistent storage support not much will work

CNI

We recommend Cilium as the CNI for the cluster, but we have also successfully tested Flannel. As we make use of calicos network policies, network isolation will not work with Flannel. Note that Calico curently does not work with Madana Core, if this is a hard requirement, please get in touch.

Important: Network ranges 10.0.1.0/24 and 10.0.2.0/24 are reserved for enclave internal networking and may not be used by the cluster network.

Deploy madana-cluster with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has madana-cluster on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartmadana-cluster is pinned at v0.0.3 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply