|
75 | 75 | from perfkitbenchmarker import configs |
76 | 76 | from perfkitbenchmarker import errors |
77 | 77 | from perfkitbenchmarker import sample |
78 | | -from perfkitbenchmarker import vm_util |
79 | | -from perfkitbenchmarker.resources.container_service import kubectl |
80 | 78 | from perfkitbenchmarker.providers.gcp import util as gcp_util |
| 79 | +from perfkitbenchmarker.resources.container_service import kubectl |
| 80 | +from perfkitbenchmarker.resources.container_service import kubernetes_commands |
81 | 81 |
|
82 | 82 | FLAGS = flags.FLAGS |
83 | 83 |
|
@@ -405,25 +405,6 @@ def __init__(self, project: str, zone: str) -> None: |
405 | 405 | self.zone = zone |
406 | 406 |
|
407 | 407 |
|
408 | | -def _daemonset_yaml(image: str) -> str: |
409 | | - """Render the privileged benchmark DaemonSet manifest. |
410 | | -
|
411 | | - The manifest is a PKB data file rendered with Jinja2 |
412 | | - (data/cluster/swap_encryption_daemonset.yaml.j2) rather than an inline |
413 | | - string, per PKB conventions. The DaemonSet is pinned to the benchmark |
414 | | - nodepool via nodeSelector so it never lands on the dummy default pool. |
415 | | - """ |
416 | | - return vm_util.ReadAndRenderJinja2Template( |
417 | | - 'cluster/swap_encryption_daemonset.yaml.j2', |
418 | | - ds_name=_DS_NAME, |
419 | | - ds_namespace=_DS_NAMESPACE, |
420 | | - ds_label=_DS_LABEL, |
421 | | - benchmark_nodepool=_BENCHMARK_NODEPOOL, |
422 | | - image=image, |
423 | | - kernel_version=_KERNEL_VERSION.value, |
424 | | - ) |
425 | | - |
426 | | - |
427 | 408 | def GetConfig(user_config: dict[str, Any]) -> dict[str, Any]: |
428 | 409 | """Load and return benchmark config spec.""" |
429 | 410 | return configs.LoadConfig(BENCHMARK_CONFIG, user_config, BENCHMARK_NAME) |
@@ -665,12 +646,22 @@ def Cleanup(spec: _BenchmarkSpec) -> None: |
665 | 646 |
|
666 | 647 |
|
667 | 648 | def _deploy_daemonset() -> None: |
668 | | - """Apply the benchmark DaemonSet manifest to the cluster.""" |
669 | | - manifest = _daemonset_yaml(image=_DAEMONSET_IMAGE.value) |
670 | | - with vm_util.NamedTemporaryFile(mode='w', suffix='.yaml') as f: |
671 | | - f.write(manifest) |
672 | | - f.close() |
673 | | - kubectl.RunKubectlCommand(['apply', '-f', f.name]) |
| 649 | + """Apply the benchmark DaemonSet manifest to the cluster. |
| 650 | +
|
| 651 | + Uses kubernetes_commands.ApplyManifest which renders the Jinja2 template |
| 652 | + from perfkitbenchmarker/data/cluster/swap_encryption_daemonset.yaml.j2, |
| 653 | + writes it to a temp file, and calls kubectl apply -f — the standard PKB |
| 654 | + pattern for deploying manifests. |
| 655 | + """ |
| 656 | + kubernetes_commands.ApplyManifest( |
| 657 | + 'cluster/swap_encryption_daemonset.yaml.j2', |
| 658 | + ds_name=_DS_NAME, |
| 659 | + ds_namespace=_DS_NAMESPACE, |
| 660 | + ds_label=_DS_LABEL, |
| 661 | + benchmark_nodepool=_BENCHMARK_NODEPOOL, |
| 662 | + image=_DAEMONSET_IMAGE.value, |
| 663 | + kernel_version=_KERNEL_VERSION.value, |
| 664 | + ) |
674 | 665 | logging.info('[swap_encryption] DaemonSet applied') |
675 | 666 |
|
676 | 667 |
|
|
0 commit comments