Skip to content

Commit

Permalink
tasks: fix installation scripts after bump to 0.8.0 (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
csegarragonz authored Feb 28, 2024
1 parent f4a8427 commit 3cf34d6
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 20 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ inv k8s.install [--clean]
You may also want to install `k9s`, a kubernetes monitoring tool:

```bash
inv k9s.install
inv k9s.install-k9s
```

## Quick Start
Expand Down
2 changes: 1 addition & 1 deletion tasks/eval/startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ def plot(ctx):
event_durations,
labels=event_labels,
colors=list(color_for_event.values()),
wedgeprops={"edgecolor": "black"}
wedgeprops={"edgecolor": "black"},
# edgecolor="black",
)

Expand Down
4 changes: 2 additions & 2 deletions tasks/eval/util/env.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from tasks.util.env import BIN_DIR, COCO_ROOT, KATA_CONFIG_DIR, PROJ_ROOT
from tasks.util.env import BIN_DIR, KATA_ROOT, KATA_CONFIG_DIR, PROJ_ROOT
from os.path import join

EVAL_ROOT = join(PROJ_ROOT, "eval")
Expand Down Expand Up @@ -46,7 +46,7 @@
"runtime_class": "kata-qemu-sev",
"cri_handler": "cc",
"image_tag": "unencrypted",
"firmware": join(COCO_ROOT, "share", "ovmf", "OVMF_CSG.fd"),
"firmware": join(KATA_ROOT, "share", "ovmf", "OVMF_CSG.fd"),
"hypervisor": join(BIN_DIR, "qemu_wrapper_remove_sev_blob.py"),
"guest_attestation": "off",
"signature_verification": "off",
Expand Down
9 changes: 8 additions & 1 deletion tasks/k8s.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from invoke import task
from os import makedirs
from os.path import exists, join
from shutil import rmtree
from subprocess import run
from tasks.util.env import BIN_DIR, CONF_FILES_DIR, K8S_VERSION
from tasks.util.network import download_binary, symlink_global_bin
Expand Down Expand Up @@ -40,7 +41,11 @@ def install_crictl():
Install the crictl container management tool
"""
work_dir = "/tmp/crictl"
makedirs(work_dir, exist_ok=True)

if exists(work_dir):
rmtree(work_dir)

makedirs(work_dir)

circtl_binary = "crictl"
circtl_version = "1.28.0"
Expand All @@ -63,6 +68,8 @@ def install_crictl():
)
symlink_global_bin(circtl_binary_path, circtl_binary)

rmtree(work_dir)


def install_k8s(clean=False):
"""
Expand Down
6 changes: 3 additions & 3 deletions tasks/kata.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from os.path import join
from subprocess import run
from tasks.util.env import (
COCO_ROOT,
KATA_ROOT,
KATA_CONFIG_DIR,
KATA_RUNTIMES,
KATA_WORKON_CTR_NAME,
Expand Down Expand Up @@ -115,12 +115,12 @@ def replace_shim(ctx, revert=False):
"""
# First, copy the binary from the source tree
src_shim_binary = join(KATA_SHIM_SOURCE_DIR, "containerd-shim-kata-v2")
dst_shim_binary = join(COCO_ROOT, "bin", "containerd-shim-kata-v2-csg")
dst_shim_binary = join(KATA_ROOT, "bin", "containerd-shim-kata-v2-csg")
copy_from_kata_workon_ctr(src_shim_binary, dst_shim_binary, sudo=True)

# Second, soft-link the SEV runtime to the right shim binary
if revert:
dst_shim_binary = join(COCO_ROOT, "bin", "containerd-shim-kata-v2")
dst_shim_binary = join(KATA_ROOT, "bin", "containerd-shim-kata-v2")

# This path is hardcoded in the containerd config/operator
sev_shim_binary = "/usr/local/bin/containerd-shim-kata-qemu-sev-v2"
Expand Down
7 changes: 6 additions & 1 deletion tasks/kubeadm.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from invoke import task
from os import getegid, geteuid
from os import getegid, geteuid, makedirs
from os.path import exists
from shutil import rmtree
from subprocess import run
from tasks.util.env import (
CRI_RUNTIME_SOCKET,
FLANNEL_VERSION,
K8S_ADMIN_FILE,
K8S_CONFIG_DIR,
KUBEADM_KUBECONFIG_FILE,
)
from tasks.util.kubeadm import (
Expand All @@ -26,6 +28,9 @@ def create(ctx):
# kubeadm_cmd = "sudo kubeadm init"
run(kubeadm_cmd, shell=True, check=True)

if not exists(K8S_CONFIG_DIR):
makedirs(K8S_CONFIG_DIR)

# Copy the config file locally and change permissions
cp_cmd = "sudo cp /etc/kubernetes/admin.conf {}".format(KUBEADM_KUBECONFIG_FILE)
run(cp_cmd, shell=True, check=True)
Expand Down
12 changes: 6 additions & 6 deletions tasks/qemu.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from invoke import task
from os.path import join
from subprocess import run
from tasks.util.env import COCO_ROOT, KATA_CONFIG_DIR, PROJ_ROOT
from tasks.util.env import KATA_ROOT, KATA_CONFIG_DIR, PROJ_ROOT
from tasks.util.toml import read_value_from_toml

QEMU_IMAGE_TAG = "qemu-build"


@task
def build(ctx, qemu_datadir=join(COCO_ROOT, "share", "kata-qemu")):
def build(ctx, qemu_datadir=join(KATA_ROOT, "share", "kata-qemu")):
"""
Build the QEMU work-on image
Expand All @@ -28,7 +28,7 @@ def build(ctx, qemu_datadir=join(COCO_ROOT, "share", "kata-qemu")):
run(docker_cmd, shell=True, check=True)

ctr_path = "/usr/src/qemu/build/qemu-system-x86_64"
host_path = join(COCO_ROOT, "bin", "qemu-system-x86_64-csg")
host_path = join(KATA_ROOT, "bin", "qemu-system-x86_64-csg")
docker_cmd = "docker cp {}:{} {}".format(
tmp_ctr_name,
ctr_path,
Expand All @@ -49,9 +49,9 @@ def standalone(ctx):
init. It is still useful to assert that the VM can boot.
"""
conf_file_path = join(KATA_CONFIG_DIR, "configuration-qemu.toml")
qemu_path = join(COCO_ROOT, "bin", "qemu-system-x86_64-csg")
fw_path = join(COCO_ROOT, "share", "ovmf", "OVMF.fd")
kernel_path = join(COCO_ROOT, "share", "kata-containers", "vmlinuz-5.19.2-109cc+")
qemu_path = join(KATA_ROOT, "bin", "qemu-system-x86_64-csg")
fw_path = join(KATA_ROOT, "share", "ovmf", "OVMF.fd")
kernel_path = join(KATA_ROOT, "share", "kata-containers", "vmlinuz-5.19.2-109cc+")

# Prepare QEMU command line
qemu_cmd = [
Expand Down
8 changes: 4 additions & 4 deletions tasks/util/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@

# CoCo config

COCO_RELEASE_VERSION = "0.7.0"
COCO_ROOT = join("/opt", "confidential-containers")
COCO_RELEASE_VERSION = "0.8.0"
KATA_ROOT = join("/opt", "kata")

# Kata config
KATA_CONFIG_DIR = join(COCO_ROOT, "share", "defaults", "kata-containers")
KATA_IMG_DIR = join(COCO_ROOT, "share", "kata-containers")
KATA_CONFIG_DIR = join(KATA_ROOT, "share", "defaults", "kata-containers")
KATA_IMG_DIR = join(KATA_ROOT, "share", "kata-containers")
KATA_WORKON_CTR_NAME = "kata-workon"
KATA_WORKON_IMAGE_TAG = "kata-build"
KATA_RUNTIMES = ["qemu", "qemu-sev"]
Expand Down
2 changes: 1 addition & 1 deletion tasks/util/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def symlink_global_bin(binary_path, name):

print("Symlinking {} -> {}".format(global_path, binary_path))
run(
"sudo ln -s {} {}".format(binary_path, name),
"sudo ln -sf {} {}".format(binary_path, name),
shell=True,
check=True,
cwd=GLOBAL_BIN_DIR,
Expand Down

0 comments on commit 3cf34d6

Please sign in to comment.