Skip to content

Commit ede471a

Browse files
authored
compose: deploy aesmd service in SGX HW mode (#90)
* compose: deploy aesmd service in SGX HW mode * compose: move all aesmd initialisation to create command
1 parent a183dae commit ede471a

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

faasmctl/util/compose.py

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,12 @@ def get_compose_env_vars(faasm_checkout, mount_source, ini_file=None):
113113
else:
114114
env["FAASM_WASM_VM"] = wasm_vm
115115

116-
if "FAASM_CLI_IMAGE" in environ and "sgx" not in wasm_vm:
117-
env["FAASM_CLI_IMAGE"] = environ["FAASM_CLI_IMAGE"]
116+
# Work out the CLI image
117+
if "FAASM_CLI_IMAGE" in environ and "sgx" not in wasm_vm:
118+
env["FAASM_CLI_IMAGE"] = environ["FAASM_CLI_IMAGE"]
118119

119-
if "FAASM_SGX_CLI_IMAGE" in environ and "sgx" in wasm_vm:
120-
env["FAASM_CLI_IMAGE"] = environ["FAASM_SGX_CLI_IMAGE"]
120+
if "FAASM_SGX_CLI_IMAGE" in environ and "sgx" in wasm_vm:
121+
env["FAASM_CLI_IMAGE"] = environ["FAASM_SGX_CLI_IMAGE"]
121122

122123
env["FAASM_OVERRIDE_CPU_COUNT"] = DEFAULT_FAASM_OVERRIDE_CPU_COUNT
123124
if "FAASM_OVERRIDE_CPU_COUNT" in environ:
@@ -151,10 +152,31 @@ def deploy_compose_cluster(faasm_checkout, workers, mount_source, ini_file):
151152
# Generate random compose project name
152153
env["COMPOSE_PROJECT_NAME"] = "faasm-{}".format(generate_gid())
153154

155+
# In a compose cluster with SGX in HW mode, we need to manually set-up
156+
# the AESMD volume and socket for remote attestation (in a k8s deployment
157+
# on AKS, this is done automatically for us)
158+
must_start_sgx_aesmd = env["FAASM_WASM_VM"] == "sgx"
159+
160+
if must_start_sgx_aesmd:
161+
docker_cmd = [
162+
"docker",
163+
"volume create",
164+
"--driver local",
165+
"--opt type=tmpfs",
166+
"--opt device=tmpfs",
167+
"--opt o=rw",
168+
"aesmd-socket",
169+
]
170+
docker_cmd = " ".join(docker_cmd)
171+
run(docker_cmd, shell=True, check=True)
172+
173+
env["SGX_DEVICE_MOUNT_DIR"] = "/dev/sgx"
174+
154175
# Deploy the compose cluster (0 workers <=> cli-only cluster)
155176
cmd = [
156177
"docker compose up -d",
157178
"--scale worker={}".format(workers) if int(workers) > 0 else "",
179+
"aesmd" if must_start_sgx_aesmd else "",
158180
"worker" if int(workers) > 0 else "faasm-cli",
159181
]
160182
cmd = " ".join(cmd)
@@ -271,6 +293,7 @@ def wait_for_venv(ini_file, cli):
271293
sleep(3)
272294

273295

296+
# TODO: make this method callable for when things go sideways
274297
def populate_host_sysroot(faasm_checkout, clean=False):
275298
"""
276299
Populate the host's sysroot under `./dev/faasm-local` to be shared by

0 commit comments

Comments
 (0)