Skip to content

Commit 52826e1

Browse files
authored
inv: import cluster creation tasks (#50)
* Merge branch 'main' into lg/cr-review-2 * revert README.md * format code * remove debug code
1 parent bdd1e94 commit 52826e1

File tree

19 files changed

+345
-45
lines changed

19 files changed

+345
-45
lines changed

K8S_VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.28.5
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{ "allowedUnsafeSysctls": ["net.*"] }

config/granny_aks_os_config.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"sysctls": {
3+
"netCoreRmemMax": 16777216,
4+
"netCoreWmemMax": 16777216,
5+
"netIpv4TcpRmem": "4096 87380 16777216",
6+
"netIpv4TcpWmem": "4096 65536 16777216",
7+
"netCoreNetdevMaxBacklog": "30000",
8+
"netCoreRmemDefault": 16777216,
9+
"netCoreWmemDefault": 16777216,
10+
"netIpv4TcpMem": "16777216 16777216 16777216",
11+
"netIpv4RouteFlush": 1
12+
}
13+
}

tasks/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
from invoke import Collection
22

3+
from . import cluster
34
from . import docker
45
from . import format_code
6+
from . import k8s
57

68
import logging
79

@@ -20,8 +22,10 @@
2022
logging.getLogger().setLevel(logging.DEBUG)
2123

2224
ns = Collection(
25+
cluster,
2326
docker,
2427
format_code,
28+
k8s,
2529
)
2630

2731
ns.add_collection(elastic_ns, name="elastic")

tasks/cluster.py

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
from invoke import task
2+
from os.path import join
3+
from subprocess import run
4+
from tasks.util.env import (
5+
AKS_CLUSTER_NAME,
6+
AKS_NODE_COUNT,
7+
AKS_REGION,
8+
AKS_VM_SIZE,
9+
AZURE_PUB_SSH_KEY,
10+
AZURE_RESOURCE_GROUP,
11+
CONFIG_DIR,
12+
KUBECTL_BIN,
13+
)
14+
from tasks.util.version import get_k8s_version
15+
16+
17+
# AKS commandline reference here:
18+
# https://docs.microsoft.com/en-us/cli/azure/aks?view=azure-cli-latest
19+
def _run_aks_cmd(name, az_args=None):
20+
cmd = [
21+
"az",
22+
"aks {}".format(name),
23+
"--resource-group {}".format(AZURE_RESOURCE_GROUP),
24+
]
25+
26+
if az_args:
27+
cmd.extend(az_args)
28+
29+
cmd = " ".join(cmd)
30+
print(cmd)
31+
run(cmd, shell=True, check=True)
32+
33+
34+
@task
35+
def list(ctx):
36+
"""
37+
List all AKS resources
38+
"""
39+
_run_aks_cmd("list")
40+
41+
42+
@task(optional=["sgx"])
43+
def provision(
44+
ctx,
45+
nodes=AKS_NODE_COUNT,
46+
vm=AKS_VM_SIZE,
47+
location=AKS_REGION,
48+
name=AKS_CLUSTER_NAME,
49+
sgx=False,
50+
granny=True,
51+
):
52+
"""
53+
Provision the AKS cluster
54+
"""
55+
k8s_ver = get_k8s_version()
56+
sgx = sgx and (sgx.lower() != "false")
57+
granny_kubelet_config = join(CONFIG_DIR, "granny_aks_kubelet_config.json")
58+
granny_os_config = join(CONFIG_DIR, "granny_aks_os_config.json")
59+
60+
if sgx and "Standard_DC" not in vm:
61+
print(
62+
"Error provisioning SGX cluster: only `Standard_DC` VMs are supported"
63+
)
64+
return
65+
66+
_run_aks_cmd(
67+
"create",
68+
[
69+
"--name {}".format(name),
70+
"--node-count {}".format(nodes),
71+
"--node-vm-size {}".format(vm),
72+
"--os-sku Ubuntu",
73+
"--kubernetes-version {}".format(k8s_ver),
74+
"--ssh-key-value {}".format(AZURE_PUB_SSH_KEY),
75+
"--location {}".format(location),
76+
"{}".format(
77+
"--kubelet-config {}".format(granny_kubelet_config)
78+
if granny
79+
else ""
80+
),
81+
"{}".format(
82+
"--linux-os-config {}".format(granny_os_config)
83+
if granny
84+
else ""
85+
),
86+
"{}".format(
87+
"--enable-addons confcom --enable-sgxquotehelper"
88+
if sgx
89+
else ""
90+
),
91+
],
92+
)
93+
94+
95+
@task
96+
def details(ctx):
97+
"""
98+
Show the details of the cluster
99+
"""
100+
_run_aks_cmd(
101+
"show",
102+
[
103+
"--name {}".format(AKS_CLUSTER_NAME),
104+
],
105+
)
106+
107+
108+
@task
109+
def delete(ctx, name=AKS_CLUSTER_NAME):
110+
"""
111+
Delete the AKS cluster
112+
"""
113+
_run_aks_cmd(
114+
"delete",
115+
[
116+
"--name {}".format(name),
117+
"--yes",
118+
],
119+
)
120+
121+
122+
@task
123+
def credentials(ctx, name=AKS_CLUSTER_NAME, out_file=None):
124+
"""
125+
Get credentials for the AKS cluster
126+
"""
127+
# Set up the credentials
128+
_run_aks_cmd(
129+
"get-credentials",
130+
[
131+
"--name {}".format(name),
132+
"--overwrite-existing",
133+
"--file {}".format(out_file) if out_file else "",
134+
],
135+
)
136+
137+
# Check we can access the cluster
138+
cmd = "{} get nodes".format(KUBECTL_BIN)
139+
print(cmd)
140+
run(cmd, shell=True, check=True)

tasks/elastic/README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Elastic Scaling Micro-Benchmark
1+
# Elastic Scaling Micro-Benchmark (Fig.12)
22

33
In this experiment we measure the benefits of elastically scaling-up OpenMP
44
applications to benefit from idle resources. We run a pipe-lined algorithm
@@ -44,6 +44,11 @@ You may now plot the results using:
4444
inv elastic.plot
4545
```
4646

47+
the plot will be available in [`/plots/elastic/elastic_speedup.pdf`](/plots/elastic/elastic_speedup.pdf), we also include it below:
48+
49+
![Elastic Scaling Plot](/plots/elastic/elastic_speedup.png)
50+
51+
4752
## Clean-Up
4853

4954
Finally, delete the Granny cluster:

tasks/k8s.py

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
from invoke import task
2+
from os.path import join, exists
3+
from os import makedirs
4+
from shutil import copy, rmtree
5+
from subprocess import run
6+
7+
from tasks.util.env import (
8+
BIN_DIR,
9+
GLOBAL_BIN_DIR,
10+
K9S_VERSION,
11+
)
12+
13+
from tasks.util.version import get_k8s_version
14+
15+
16+
def _download_binary(url, binary_name):
17+
makedirs(BIN_DIR, exist_ok=True)
18+
cmd = "curl -LO {}".format(url)
19+
run(cmd, shell=True, check=True, cwd=BIN_DIR)
20+
run("chmod +x {}".format(binary_name), shell=True, check=True, cwd=BIN_DIR)
21+
22+
return join(BIN_DIR, binary_name)
23+
24+
25+
def _symlink_global_bin(binary_path, name):
26+
global_path = join(GLOBAL_BIN_DIR, name)
27+
if exists(global_path):
28+
print("Removing existing binary at {}".format(global_path))
29+
run(
30+
"sudo rm -f {}".format(global_path),
31+
shell=True,
32+
check=True,
33+
)
34+
35+
print("Symlinking {} -> {}".format(global_path, binary_path))
36+
run(
37+
"sudo ln -s {} {}".format(binary_path, name),
38+
shell=True,
39+
check=True,
40+
cwd=GLOBAL_BIN_DIR,
41+
)
42+
43+
44+
@task
45+
def install_kubectl(ctx, system=False):
46+
"""
47+
Install the k8s CLI (kubectl)
48+
"""
49+
k8s_ver = get_k8s_version()
50+
url = "https://dl.k8s.io/release/v{}/bin/linux/amd64/kubectl".format(
51+
k8s_ver
52+
)
53+
54+
binary_path = _download_binary(url, "kubectl")
55+
56+
# Symlink for kubectl globally
57+
if system:
58+
_symlink_global_bin(binary_path, "kubectl")
59+
60+
61+
@task
62+
def install_k9s(ctx, system=False):
63+
"""
64+
Install the K9s CLI
65+
"""
66+
tar_name = "k9s_Linux_amd64.tar.gz"
67+
url = "https://github.com/derailed/k9s/releases/download/v{}/{}".format(
68+
K9S_VERSION, tar_name
69+
)
70+
print(url)
71+
72+
# Download the TAR
73+
workdir = "/tmp/k9s-csg"
74+
makedirs(workdir, exist_ok=True)
75+
76+
cmd = "curl -LO {}".format(url)
77+
run(cmd, shell=True, check=True, cwd=workdir)
78+
79+
# Untar
80+
run("tar -xf {}".format(tar_name), shell=True, check=True, cwd=workdir)
81+
82+
# Copy k9s into place
83+
binary_path = join(BIN_DIR, "k9s")
84+
copy(join(workdir, "k9s"), binary_path)
85+
86+
# Remove tar
87+
rmtree(workdir)
88+
89+
# Symlink for k9s command globally
90+
if system:
91+
_symlink_global_bin(binary_path, "k9s")

tasks/kernels_mpi/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# ParRes Kernels Experiment (MPI)
1+
# ParRes Kernels Experiment - MPI (Fig.9b)
22

33
This experiment runs a set of the [ParRes Kernels](https://github.com/ParRes/Kernels)
44
as a microbenchmark for Granny's MPI implementation.
55

66
## Start AKS cluster
77

8-
In the `experiment-base` terminal, run:
8+
Create a new cluster:
99

1010
```bash
1111
inv cluster.provision --vm Standard_D8_v5 --nodes 3 cluster.credentials
@@ -63,8 +63,9 @@ To plot the results, just run:
6363
inv kernels-mpi.plot
6464
```
6565

66-
the plot will be available in [`./plots/kernels-mpi/mpi_kernels_slowdown.pdf`](
67-
./plots/kernels-mpi/mpi_kernels_slowdown.pdf).
66+
the plot will be available in [`/plots/kernels-mpi/mpi_kernels_slowdown.pdf`](/plots/kernels-mpi/mpi_kernels_slowdown.pdf), we also include it below:
67+
68+
![MPI Kernels Slowdown Plot](/plots/kernels-mpi/mpi_kernels_slowdown.png)
6869

6970
## Clean-up
7071

tasks/kernels_omp/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# ParRes Kernels Experiment (OpenMP)
1+
# ParRes Kernels Experiment - OpenMP (Fig.10)
22

33
This experiment runs a set of the [ParRes Kernels](https://github.com/ParRes/Kernels)
44
as a microbenchmark for Granny's OpenMP implementation.
55

66
## Start AKS cluster
77

8-
In the `experiment-base` terminal, run:
8+
Create a new cluster:
99

1010
```bash
1111
inv cluster.provision --vm Standard_D8_v5 --nodes 2 cluster.credentials
@@ -63,8 +63,9 @@ To plot the results, just run:
6363
inv kernels-omp.plot
6464
```
6565

66-
the plot will be available in [`./plots/kernels-omp/openmp_kernels_slowdown.pdf`](
67-
./plots/kernels-omp/openmp_kernels_slowdown.pdf).
66+
the plot will be available in [`/plots/kernels-omp/openmp_kernels_slowdown.pdf`](/plots/kernels-omp/openmp_kernels_slowdown.pdf), we also include it below:
67+
68+
![OpenMP Kernels Slowdown Plot](/plots/kernels-omp/openmp_kernels_slowdown.png)
6869

6970
## Clean-up
7071

tasks/lammps/README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
# LAMMPS Experiment
1+
# LAMMPS Experiment (Fig.9a)
22

33
This experiment is a single execution of the LAMMPS simulation stress tested
44
as part of the array experiment.
55

66
## Start AKS cluster
77

8-
In the `experiment-base` terminal, run:
8+
Create a new cluster:
99

1010
```bash
11-
inv cluster.provision --vm Standard_D8_v5 --nodes 3
12-
inv cluster.credentials
11+
inv cluster.provision --vm Standard_D8_v5 --nodes 3 cluster.credentials
1312
```
1413

1514
## Granny
@@ -66,10 +65,10 @@ To plot the results, you may run:
6665
inv lammps.plot
6766
```
6867

69-
which will generate a plot in [`./plots/lammps/runtime.png`](
70-
./plots/lammps/runtime.png), we also include it below:
68+
which will generate a plot in [`/plots/lammps/lammps_slowdown.png`](
69+
/plots/lammps/lammps_slowdown.png), we also include it below:
7170

72-
![LAMMPS Runtime Plot](./plots/lammps/runtime.png)
71+
![LAMMPS Runtime Plot](/plots/lammps/lammps_slowdown.png)
7372

7473
## Clean-Up
7574

0 commit comments

Comments
 (0)