Skip to content

Commit

Permalink
Support num nodes for kubernetes
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Gu <[email protected]>
  • Loading branch information
tylergu committed Jun 14, 2024
1 parent 508165d commit d98bc65
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion acto/kubernetes_engine/kind.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def __init__(
extra_mounts.append(
{"hostPath": "profile/data", "containerPath": "/tmp/profile"}
)
for _ in range(num_nodes - 1):
for _ in range(num_nodes):
config_dict["nodes"].append(
{
"role": "worker",
Expand Down
17 changes: 17 additions & 0 deletions chactos/fault_injection_config.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
from typing import Optional

import pydantic

from acto.lib.operator_config import DeployConfig


class KubernetesConfig(pydantic.BaseModel, extra="forbid"):
"""Kubernetes Config"""

num_nodes: int = pydantic.Field(
description="Number of workers in the Kubernetes cluster", default=4
)
version: str = pydantic.Field(
default="v1.28.0", description="Kubernetes version"
)
feature_gates: Optional[dict[str, bool]] = pydantic.Field(
description="Path to the feature gates file", default=None
)


class FaultInjectionConfig(pydantic.BaseModel, extra="forbid"):
"""Fault Injection Config"""

Expand All @@ -11,3 +27,4 @@ class FaultInjectionConfig(pydantic.BaseModel, extra="forbid"):
operator_selector: dict
application_pod_prefix: str
input_dir: str
kubernetes: KubernetesConfig
4 changes: 3 additions & 1 deletion chactos/fault_injections.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ def __init__(self, operator_config: FaultInjectionConfig, worker_id: int):

def run(self):
"""Run the experiment."""
k8s_cluster_engine: KubernetesEngine = Kind(0)
k8s_cluster_engine: KubernetesEngine = Kind(
0, num_nodes=self._operator_config.num_nodes
)
cluster_name = f"acto-cluster-{self._worker_id}"
kubecontext = k8s_cluster_engine.get_context_name(cluster_name)
kubeconfig = os.path.join(os.path.expanduser("~"), ".kube", kubecontext)
Expand Down
5 changes: 4 additions & 1 deletion chactos/percona-mongodb-operator.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@
"labelSelectors": {"name": "percona-server-mongodb-operator"}
},
"application_pod_prefix": "test-cluster-rs0-",
"input_dir": "data/percona-server-mongodb-operator/v1.16.0/inputs"
"input_dir": "data/percona-server-mongodb-operator/v1.16.0/inputs",
"kubernetes": {
"num_nodes": 7
}
}

0 comments on commit d98bc65

Please sign in to comment.