From fff675f3dd7679a54e451fce7155371ee1a03474 Mon Sep 17 00:00:00 2001 From: Tullio Sebastiani Date: Wed, 23 Jul 2025 10:17:50 +0200 Subject: [PATCH] added service account to Network Chaos NG workload (#870) Signed-off-by: Tullio Sebastiani --- krkn/scenario_plugins/network_chaos_ng/models.py | 1 + .../network_chaos_ng/modules/templates/network-chaos.j2 | 3 +++ .../network_chaos_ng/modules/utils_network_filter.py | 3 ++- scenarios/kube/node-network-filter.yml | 1 + scenarios/kube/pod-network-filter.yml | 1 + 5 files changed, 8 insertions(+), 1 deletion(-) diff --git a/krkn/scenario_plugins/network_chaos_ng/models.py b/krkn/scenario_plugins/network_chaos_ng/models.py index 54b7f8ff..a0f5e2d1 100644 --- a/krkn/scenario_plugins/network_chaos_ng/models.py +++ b/krkn/scenario_plugins/network_chaos_ng/models.py @@ -14,6 +14,7 @@ class BaseNetworkChaosConfig: wait_duration: int test_duration: int label_selector: str + service_account: str instance_count: int execution: str namespace: str diff --git a/krkn/scenario_plugins/network_chaos_ng/modules/templates/network-chaos.j2 b/krkn/scenario_plugins/network_chaos_ng/modules/templates/network-chaos.j2 index 4d7e9aaa..33cbc001 100644 --- a/krkn/scenario_plugins/network_chaos_ng/modules/templates/network-chaos.j2 +++ b/krkn/scenario_plugins/network_chaos_ng/modules/templates/network-chaos.j2 @@ -4,6 +4,9 @@ metadata: name: {{pod_name}} namespace: {{namespace}} spec: + {% if service_account %} + serviceAccountName: {{ service_account }} + {%endif%} {% if host_network %} hostNetwork: true {%endif%} diff --git a/krkn/scenario_plugins/network_chaos_ng/modules/utils_network_filter.py b/krkn/scenario_plugins/network_chaos_ng/modules/utils_network_filter.py index e5519859..1bdefae4 100644 --- a/krkn/scenario_plugins/network_chaos_ng/modules/utils_network_filter.py +++ b/krkn/scenario_plugins/network_chaos_ng/modules/utils_network_filter.py @@ -87,7 +87,8 @@ def deploy_network_filter_pod( target=target_node, container_name=container_name, workload_image=config.image, - taints=tolerations + taints=tolerations, + service_account=config.service_account ) ) diff --git a/scenarios/kube/node-network-filter.yml b/scenarios/kube/node-network-filter.yml index bff97614..86458e86 100644 --- a/scenarios/kube/node-network-filter.yml +++ b/scenarios/kube/node-network-filter.yml @@ -3,6 +3,7 @@ wait_duration: 1 test_duration: 10 label_selector: "" + service_account: "" taints: [] # example ["node-role.kubernetes.io/master:NoSchedule"] namespace: 'default' instance_count: 1 diff --git a/scenarios/kube/pod-network-filter.yml b/scenarios/kube/pod-network-filter.yml index bfc9bb31..1d6ca246 100644 --- a/scenarios/kube/pod-network-filter.yml +++ b/scenarios/kube/pod-network-filter.yml @@ -3,6 +3,7 @@ wait_duration: 1 test_duration: 60 label_selector: "" + service_account: "" taints: [] # example ["node-role.kubernetes.io/master:NoSchedule"] namespace: 'default' instance_count: 1